summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2018-05-15 00:24:58 +0200
committerGravatar Nikias Bassen2018-05-15 00:24:58 +0200
commitca6f4718deb56367bbae33312e0f341e0595f3eb (patch)
treefe340651fe83cadc4ca5ecae5fe6a5e3c3c9e186 /src
parent065a2cd678f5335c14d157dc0bc35286e562a4d6 (diff)
downloadusbmuxd-ca6f4718deb56367bbae33312e0f341e0595f3eb.tar.gz
usbmuxd-ca6f4718deb56367bbae33312e0f341e0595f3eb.tar.bz2
client: Set socket options for client connections to improve performance
Diffstat (limited to 'src')
-rw-r--r--src/client.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/client.c b/src/client.c
index a9d09d3..a9c986a 100644
--- a/src/client.c
+++ b/src/client.c
@@ -30,6 +30,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <netinet/tcp.h>
#include <sys/un.h>
#include <arpa/inet.h>
#include <pthread.h>
@@ -171,6 +172,17 @@ int client_accept(int listenfd)
}
}
+ int bufsize = 0x20000;
+ if (setsockopt(cfd, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(int)) == -1) {
+ usbmuxd_log(LL_WARNING, "Could not set send buffer for client socket");
+ }
+ if (setsockopt(cfd, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(int)) == -1) {
+ usbmuxd_log(LL_WARNING, "Could not set receive buffer for client socket");
+ }
+
+ int yes = 1;
+ setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, (void*)&yes, sizeof(int));
+
struct mux_client *client;
client = malloc(sizeof(struct mux_client));
memset(client, 0, sizeof(struct mux_client));