Skip to content

Instantly share code, notes, and snippets.

@godmar
Created April 30, 2018 03:32
Show Gist options
  • Save godmar/91934de8ffb5addb8e82b4a20c28d251 to your computer and use it in GitHub Desktop.
Save godmar/91934de8ffb5addb8e82b4a20c28d251 to your computer and use it in GitHub Desktop.
patch for socket.c that turns on TCP_NODELAY
diff --git a/src-solution/socket.c b/src-solution/socket.c
index 112e12b..6f0c402 100644
--- a/src-solution/socket.c
+++ b/src-solution/socket.c
@@ -13,6 +13,7 @@
#include <sys/sendfile.h>
#include <netdb.h>
#include <netinet/in.h>
+#include <netinet/tcp.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
@@ -145,6 +146,9 @@ socket_accept_client(int accepting_socket)
return -1;
}
+ int i = 1;
+ setsockopt(client, IPPROTO_TCP, TCP_NODELAY, (void *)&i, sizeof(i));
+
/* The following will help with debugging your server.
* Adjust and/or remove as you see fit.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment