summaryrefslogtreecommitdiff
path: root/src/ivysocket.c
diff options
context:
space:
mode:
authorbustico2009-07-06 10:22:07 +0000
committerbustico2009-07-06 10:22:07 +0000
commitc11ddf39df8c9ea9e08410277b3a476961ad1df2 (patch)
tree7191b170cf58b0546b08025a9d1b1ba6040c3017 /src/ivysocket.c
parent41ab25636882f12eed1c31a818a70aed12a46bbf (diff)
downloadivy-c-c11ddf39df8c9ea9e08410277b3a476961ad1df2.zip
ivy-c-c11ddf39df8c9ea9e08410277b3a476961ad1df2.tar.gz
ivy-c-c11ddf39df8c9ea9e08410277b3a476961ad1df2.tar.bz2
ivy-c-c11ddf39df8c9ea9e08410277b3a476961ad1df2.tar.xz
force tcp_no_delay option to reduce lag on small messages
Diffstat (limited to 'src/ivysocket.c')
-rw-r--r--src/ivysocket.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/ivysocket.c b/src/ivysocket.c
index 200074e..09fe251 100644
--- a/src/ivysocket.c
+++ b/src/ivysocket.c
@@ -14,6 +14,8 @@
* copyright notice regarding this software
*/
+
+
#ifdef OPENMP
#include <omp.h>
#endif
@@ -27,6 +29,7 @@
#include <stdarg.h>
#include <string.h>
#include <fcntl.h>
+#include <netinet/tcp.h>
#ifdef WIN32
#ifndef __MINGW32__
@@ -265,6 +268,19 @@ static void HandleServer(Channel channel, HANDLE fd, void *data)
fprintf(stderr,"Warning : Setting socket in nonblock mode FAILED\n");
}
#endif
+ if (setsockopt(client->fd, /* socket affected */
+ IPPROTO_TCP, /* set option at TCP level */
+ TCP_NODELAY, /* name of option */
+ (char *) &_TCP_NO_DELAY_ACTIVATED, /* the cast is historical */
+ sizeof(_TCP_NO_DELAY_ACTIVATED)) < 0) /* length of option value */
+ {
+#ifdef WIN32
+ fprintf(stderr," setsockopt %d\n",WSAGetLastError());
+#endif
+ perror ("*** set socket option TCP_NODELAY***");
+ exit(0);
+ }
+
@@ -656,6 +672,20 @@ Client SocketConnectAddr (struct in_addr * addr, unsigned short port,
fprintf(stderr,"Warning : Setting socket in nonblock mode FAILED\n");
}
#endif
+ if (setsockopt(handle, /* socket affected */
+ IPPROTO_TCP, /* set option at TCP level */
+ TCP_NODELAY, /* name of option */
+ (char *) &_TCP_NO_DELAY_ACTIVATED, /* the cast is historical */
+ sizeof(_TCP_NO_DELAY_ACTIVATED)) < 0) /* length of option value */
+ {
+#ifdef WIN32
+ fprintf(stderr," setsockopt %d\n",WSAGetLastError());
+#endif
+ perror ("*** set socket option TCP_NODELAY***");
+ exit(0);
+ }
+
+
IVY_LIST_ADD_START(clients_list, client );
client->buffer_size = IVY_BUFFER_SIZE;