summaryrefslogtreecommitdiffhomepage
path: root/win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32.c')
-rw-r--r--win32.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/win32.c b/win32.c
index 9559154..27e7877 100644
--- a/win32.c
+++ b/win32.c
@@ -104,24 +104,11 @@ ENetSocket
enet_socket_create (ENetSocketType type, const ENetAddress * address)
{
ENetSocket newSocket = socket (PF_INET, type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0);
- u_long nonBlocking = 1;
- int receiveBufferSize = ENET_HOST_RECEIVE_BUFFER_SIZE,
- sendBufferSize = ENET_HOST_SEND_BUFFER_SIZE,
- allowBroadcasting = 1;
struct sockaddr_in sin;
if (newSocket == ENET_SOCKET_NULL)
return ENET_SOCKET_NULL;
- if (type == ENET_SOCKET_TYPE_DATAGRAM)
- {
- ioctlsocket (newSocket, FIONBIO, & nonBlocking);
-
- setsockopt (newSocket, SOL_SOCKET, SO_RCVBUF, (char *) & receiveBufferSize, sizeof (int));
- setsockopt (newSocket, SOL_SOCKET, SO_SNDBUF, (char *) & sendBufferSize, sizeof (int));
- setsockopt (newSocket, SOL_SOCKET, SO_BROADCAST, (char *) & allowBroadcasting, sizeof (int));
- }
-
memset (& sin, 0, sizeof (struct sockaddr_in));
sin.sin_family = AF_INET;
@@ -154,6 +141,37 @@ enet_socket_create (ENetSocketType type, const ENetAddress * address)
}
int
+enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value)
+{
+ int result = SOCKET_ERROR;
+ switch (option)
+ {
+ case ENET_SOCKOPT_NONBLOCK:
+ {
+ u_long nonBlocking = (u_long) value;
+ result = ioctlsocket (socket, FIONBIO, & nonBlocking);
+ break;
+ }
+
+ case ENET_SOCKOPT_BROADCAST:
+ result = setsockopt (socket, SOL_SOCKET, SO_BROADCAST, (char *) & value, sizeof (int));
+ break;
+
+ case ENET_SOCKOPT_RCVBUF:
+ result = setsockopt (socket, SOL_SOCKET, SO_RCVBUF, (char *) & value, sizeof (int));
+ break;
+
+ case ENET_SOCKOPT_SNDBUF:
+ result = setsockopt (socket, SOL_SOCKET, SO_SNDBUF, (char *) & value, sizeof (int));
+ break;
+
+ default:
+ break;
+ }
+ return result == SOCKET_ERROR ? -1 : 0;
+}
+
+int
enet_socket_connect (ENetSocket socket, const ENetAddress * address)
{
struct sockaddr_in sin;