diff --git a/feature_wishlist.txt b/feature_wishlist.txt index df095cb..3da2a33 100644 --- a/feature_wishlist.txt +++ b/feature_wishlist.txt @@ -1,6 +1,3 @@ -- remove Nagle algorithm - - use TCP_NODELAY - - support multiple client connections at the same time - first client has control - additional clients can see the traffic diff --git a/moxerver.h b/moxerver.h index 4ebafe7..a24f0fc 100644 --- a/moxerver.h +++ b/moxerver.h @@ -5,6 +5,7 @@ #include #include #include +#include /* TCP_NODELAY */ #include #include diff --git a/server.c b/server.c index 482e5e5..c2a9f99 100644 --- a/server.c +++ b/server.c @@ -25,6 +25,12 @@ int server_setup(struct server_t *server, unsigned int port) { fprintf(stderr, "[%s:%d] error %d: %s\n", __func__, __LINE__, errno, strerror(errno)); return -errno; } + /* turn off Nagle algorithm */ + opt = 1; /* true value for setsockopt option */ + if (setsockopt(server->socket, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(int)) == -1) { + fprintf(stderr, "[%s:%d] error %d: %s\n", __func__, __LINE__, errno, strerror(errno)); + return -errno; + } /* bind server address to a socket */ if (bind(server->socket, (struct sockaddr *) &server->address, sizeof(server->address)) == -1) {