diff options
author | Mikhail Burakov <mburakov@mailbox.org> | 2024-05-05 15:15:45 +0200 |
---|---|---|
committer | Mikhail Burakov <mburakov@mailbox.org> | 2024-05-05 15:15:45 +0200 |
commit | 0f19915421fb2398fb4753bf2d427ef5c447c0dd (patch) | |
tree | b16dbbd31ca37c02242ab1d46f9dc1d32fc35d1c | |
parent | cca29bc591e3309fcdc650c8b9463e254414de43 (diff) |
Set TCP_NODELAY on accepted client connections
-rw-r--r-- | main.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -17,11 +17,13 @@ #include <errno.h> #include <netinet/in.h> +#include <netinet/tcp.h> #include <signal.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/socket.h> #include <unistd.h> #include "capture.h" @@ -228,6 +230,11 @@ static void OnClientConnecting(void* user) { return; } + if (setsockopt(client_fd, IPPROTO_TCP, TCP_NODELAY, &(int){1}, sizeof(int))) { + LOG("Failed to set TCP_NODELAY (%s)", strerror(errno)); + goto drop_client; + } + contexts->client_fd = client_fd; if (!IoMuxerOnRead(&contexts->io_muxer, contexts->client_fd, &OnClientWriting, user)) { |