aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32.c
diff options
context:
space:
mode:
authorLee Salzman <[email protected]>2012-09-18 16:38:10 +0300
committerLee Salzman <[email protected]>2012-09-18 16:38:10 +0300
commit0e0ace781b3d41c08d310e678f4e08e323a6a3b8 (patch)
treec1bfa74351a74ab5b00ec2a5fe9e74d8b415a1a7 /win32.c
parent74d4c4a88fb274b068352512d8d0dfa3ff819d56 (diff)
downloadenet-0e0ace781b3d41c08d310e678f4e08e323a6a3b8.tar.gz
enet-0e0ace781b3d41c08d310e678f4e08e323a6a3b8.zip
merging some things from Ryan C. Gordon (icculus):
enet_socket_connect() shouldn't fail with non-blocking sockets. Removed unused variable. Sanity check for possible NULL dereference reported by clang's static…analysis. Added an interface to shutdown(). Fixed typo in the comments.
Diffstat (limited to 'win32.c')
-rw-r--r--win32.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/win32.c b/win32.c
index 708d306..850d8a3 100644
--- a/win32.c
+++ b/win32.c
@@ -184,6 +184,7 @@ int
enet_socket_connect (ENetSocket socket, const ENetAddress * address)
{
struct sockaddr_in sin;
+ int result;
memset (& sin, 0, sizeof (struct sockaddr_in));
@@ -191,7 +192,11 @@ enet_socket_connect (ENetSocket socket, const ENetAddress * address)
sin.sin_port = ENET_HOST_TO_NET_16 (address -> port);
sin.sin_addr.s_addr = address -> host;
- return connect (socket, (struct sockaddr *) & sin, sizeof (struct sockaddr_in)) == SOCKET_ERROR ? -1 : 0;
+ result = connect (socket, (struct sockaddr *) & sin, sizeof (struct sockaddr_in));
+ if (result == SOCKET_ERROR && WSAGetLastError () != EWOULDBLOCK)
+ return -1;
+
+ return 0;
}
ENetSocket
@@ -217,6 +222,12 @@ enet_socket_accept (ENetSocket socket, ENetAddress * address)
return result;
}
+int
+enet_socket_shutdown (ENetSocket socket, ENetSocketShutdown how)
+{
+ return shutdown (socket, (int) how) == SOCKET_ERROR ? -1 : 0;
+}
+
void
enet_socket_destroy (ENetSocket socket)
{