aboutsummaryrefslogtreecommitdiffhomepage
path: root/unix.c
diff options
context:
space:
mode:
authorlsalzman <[email protected]>2013-09-27 09:42:37 +0300
committerlsalzman <[email protected]>2013-09-27 09:42:37 +0300
commit2c5dd69b176f1a3089bc10affc0c65d7fcbbab07 (patch)
tree47d6f53e20b651ee1cdf14c2b46312ccb376f0b6 /unix.c
parentbc8019aa15a1e9357d9246369e2c3db658f06085 (diff)
downloadenet-2c5dd69b176f1a3089bc10affc0c65d7fcbbab07.tar.gz
enet-2c5dd69b176f1a3089bc10affc0c65d7fcbbab07.zip
fix RCVTIMEO and SNDTIMEO options on unix and also add NODELAY
Diffstat (limited to 'unix.c')
-rw-r--r--unix.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/unix.c b/unix.c
index f04bb6d..3fdce96 100644
--- a/unix.c
+++ b/unix.c
@@ -9,6 +9,7 @@
#include <sys/ioctl.h>
#include <sys/time.h>
#include <arpa/inet.h>
+#include <netinet/tcp.h>
#include <netdb.h>
#include <unistd.h>
#include <string.h>
@@ -258,11 +259,25 @@ enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value)
break;
case ENET_SOCKOPT_RCVTIMEO:
- result = setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) & value, sizeof (int));
+ {
+ struct timeval timeVal;
+ timeVal.tv_sec = value / 1000;
+ timeVal.tv_usec = (value % 1000) * 1000;
+ result = setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) & timeVal, sizeof (struct timeval));
break;
+ }
case ENET_SOCKOPT_SNDTIMEO:
- result = setsockopt (socket, SOL_SOCKET, SO_SNDTIMEO, (char *) & value, sizeof (int));
+ {
+ struct timeval timeVal;
+ timeVal.tv_sec = value / 1000;
+ timeVal.tv_usec = (value % 1000) * 1000;
+ result = setsockopt (socket, SOL_SOCKET, SO_SNDTIMEO, (char *) & timeVal, sizeof (struct timeval));
+ break;
+ }
+
+ case ENET_SOCKOPT_NODELAY:
+ result = setsockopt (socket, IPPROTO_TCP, TCP_NODELAY, (char *) & value, sizeof (int));
break;
default: