summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/socket.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/common/socket.c b/common/socket.c
index 4cdefd6..30b2b8c 100644
--- a/common/socket.c
+++ b/common/socket.c
@@ -35,6 +35,7 @@ static int wsa_init = 0;
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
+#include <netinet/tcp.h>
#include <netdb.h>
#include <arpa/inet.h>
#endif
@@ -116,6 +117,7 @@ int socket_connect_unix(const char *filename)
#ifdef SO_NOSIGPIPE
int yes = 1;
#endif
+ int bufsize = 0x20000;
// check if socket file exists...
if (stat(filename, &fst) != 0) {
@@ -138,6 +140,14 @@ int socket_connect_unix(const char *filename)
return -1;
}
+ if (setsockopt(sfd, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(int)) == -1) {
+ perror("Could not set send buffer for socket");
+ }
+
+ if (setsockopt(sfd, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(int)) == -1) {
+ perror("Could not set receive buffer for socket");
+ }
+
#ifdef SO_NOSIGPIPE
if (setsockopt(sfd, SOL_SOCKET, SO_NOSIGPIPE, (void*)&yes, sizeof(int)) == -1) {
perror("setsockopt()");
@@ -225,6 +235,7 @@ int socket_connect(const char *addr, uint16_t port)
{
int sfd = -1;
int yes = 1;
+ int bufsize = 0x20000;
struct hostent *hp;
struct sockaddr_in saddr;
#ifdef WIN32
@@ -275,6 +286,18 @@ int socket_connect(const char *addr, uint16_t port)
}
#endif
+ if (setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, (void*)&yes, sizeof(int)) == -1) {
+ perror("Could not set TCP_NODELAY on socket");
+ }
+
+ if (setsockopt(sfd, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(int)) == -1) {
+ perror("Could not set send buffer for socket");
+ }
+
+ if (setsockopt(sfd, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(int)) == -1) {
+ perror("Could not set receive buffer for socket");
+ }
+
memset((void *) &saddr, 0, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_addr.s_addr = *(uint32_t *) hp->h_addr;