diff options
author | Lee Salzman <[email protected]> | 2012-09-18 16:38:10 +0300 |
---|---|---|
committer | Lee Salzman <[email protected]> | 2012-09-18 16:38:10 +0300 |
commit | 0e0ace781b3d41c08d310e678f4e08e323a6a3b8 (patch) | |
tree | c1bfa74351a74ab5b00ec2a5fe9e74d8b415a1a7 /unix.c | |
parent | 74d4c4a88fb274b068352512d8d0dfa3ff819d56 (diff) | |
download | enet-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.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -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) { |