aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/enet/enet.h3
-rw-r--r--unix.c19
-rw-r--r--win32.c4
3 files changed, 23 insertions, 3 deletions
diff --git a/include/enet/enet.h b/include/enet/enet.h
index 162b0f8..c690e42 100644
--- a/include/enet/enet.h
+++ b/include/enet/enet.h
@@ -61,7 +61,8 @@ typedef enum _ENetSocketOption
ENET_SOCKOPT_REUSEADDR = 5,
ENET_SOCKOPT_RCVTIMEO = 6,
ENET_SOCKOPT_SNDTIMEO = 7,
- ENET_SOCKOPT_ERROR = 8
+ ENET_SOCKOPT_ERROR = 8,
+ ENET_SOCKOPT_NODELAY = 9
} ENetSocketOption;
typedef enum _ENetSocketShutdown
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:
diff --git a/win32.c b/win32.c
index 057f82c..c441841 100644
--- a/win32.c
+++ b/win32.c
@@ -195,6 +195,10 @@ enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value)
result = setsockopt (socket, SOL_SOCKET, SO_SNDTIMEO, (char *) & value, sizeof (int));
break;
+ case ENET_SOCKOPT_NODELAY:
+ result = setsockopt (socket, IPPROTO_TCP, TCP_NODELAY, (char *) & value, sizeof (int));
+ break;
+
default:
break;
}