summaryrefslogtreecommitdiffhomepage
path: root/unix.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 /unix.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 'unix.c')
-rw-r--r--unix.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/unix.c b/unix.c
index 7bbe77a..d425b4b 100644
--- a/unix.c
+++ b/unix.c
@@ -254,6 +254,7 @@ int
enet_socket_connect (ENetSocket socket, const ENetAddress * address)
{
struct sockaddr_in sin;
+ int result;
memset (& sin, 0, sizeof (struct sockaddr_in));
@@ -261,7 +262,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));
+ result = connect (socket, (struct sockaddr *) & sin, sizeof (struct sockaddr_in));
+ if (result == -1 && errno == EINPROGRESS)
+ return 0;
+
+ return result;
}
ENetSocket
@@ -287,6 +292,12 @@ enet_socket_accept (ENetSocket socket, ENetAddress * address)
return result;
}
+int
+enet_socket_shutdown (ENetSocket socket, ENetSocketShutdown how)
+{
+ return shutdown (socket, (int) how);
+}
+
void
enet_socket_destroy (ENetSocket socket)
{