Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eb7126c662 | |||
| 4ce4aac149 | |||
| 8ff344897a | |||
| 5ff8ccb74f | |||
| 9185dc80bc | |||
| 2e708e5908 | |||
| 65f71f82b8 | |||
| d7c0ce8240 | |||
| 2c413b2353 | |||
| c74ac8b844 | |||
| 77cc156305 | |||
| 2d979ceb51 | |||
| 9dff8f72cf | |||
| 0e0ace781b | |||
| 74d4c4a88f | |||
| 0fd4c9389b | |||
| 71b7550049 |
@@ -1,3 +1,17 @@
|
||||
ENet 1.3.7 (March 6, 2013):
|
||||
|
||||
* added ENET_PACKET_FLAG_SENT to indicate that a packet is being freed because it has been sent
|
||||
* added userData field to ENetPacket
|
||||
* changed how random seed is generated on Windows to avoid import warnings
|
||||
* fixed case where disconnects could be generated with no preceding connect event
|
||||
|
||||
ENet 1.3.6 (December 11, 2012):
|
||||
|
||||
* added support for intercept callback in ENetHost that can be used to process raw packets before ENet
|
||||
* added enet_socket_shutdown() for issuing shutdown on a socket
|
||||
* fixed enet_socket_connect() to not error on non-blocking connects
|
||||
* fixed bug in MTU negotiation during connections
|
||||
|
||||
ENet 1.3.5 (July 31, 2012):
|
||||
|
||||
* fixed bug in unreliable packet fragment queuing
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2002-2012 Lee Salzman
|
||||
Copyright (c) 2002-2013 Lee Salzman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ enetinclude_HEADERS = \
|
||||
lib_LTLIBRARIES = libenet.la
|
||||
libenet_la_SOURCES = callbacks.c compress.c host.c list.c packet.c peer.c protocol.c unix.c win32.c
|
||||
# see info '(libtool) Updating version info' before making a release
|
||||
libenet_la_LDFLAGS = $(AM_LDFLAGS) -version-info 2:0:0
|
||||
libenet_la_LDFLAGS = $(AM_LDFLAGS) -version-info 4:0:2
|
||||
INCLUDES = -I$(top_srcdir)/include
|
||||
|
||||
ACLOCAL_AMFLAGS = -Im4
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
AC_INIT([libenet], [1.3.5])
|
||||
AC_INIT([libenet], [1.3.7])
|
||||
AC_CONFIG_SRCDIR([include/enet/enet.h])
|
||||
AM_INIT_AUTOMAKE([foreign])
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
@page License License
|
||||
|
||||
Copyright (c) 2002-2012 Lee Salzman
|
||||
Copyright (c) 2002-2013 Lee Salzman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ portable, and easily embeddable.
|
||||
You can retrieve the source to ENet by downloading it in either .tar.gz form
|
||||
or accessing the github distribution directly.
|
||||
|
||||
The most recent stable release (1.3.5) can be downloaded <a href="http://enet.bespin.org/download/enet-1.3.5.tar.gz">here</a>.
|
||||
The most recent stable release (1.3.7) can be downloaded <a href="http://enet.bespin.org/download/enet-1.3.7.tar.gz">here</a>.
|
||||
The last release that is protocol compatible with the 1.2 series or earlier (1.2.5) can be downloaded <a href="http://enet.bespin.org/download/enet-1.2.5.tar.gz">here</a>
|
||||
|
||||
You can find the most recent ENet source at <a href="https://github.com/lsalzman/enet">the github repository</a>.
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
@brief ENet host management functions
|
||||
*/
|
||||
#define ENET_BUILDING_LIB 1
|
||||
#define __MINGW_USE_VC2005_COMPAT 1
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "enet/enet.h"
|
||||
@@ -76,7 +75,12 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
|
||||
if (channelLimit < ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT)
|
||||
channelLimit = ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT;
|
||||
|
||||
host -> randomSeed = (enet_uint32) time(NULL) + (enet_uint32) (size_t) host;
|
||||
host -> randomSeed = (enet_uint32) (size_t) host;
|
||||
#ifdef WIN32
|
||||
host -> randomSeed += (enet_uint32) timeGetTime();
|
||||
#else
|
||||
host -> randomSeed += (enet_uint32) time(NULL);
|
||||
#endif
|
||||
host -> randomSeed = (host -> randomSeed << 16) | (host -> randomSeed >> 16);
|
||||
host -> channelLimit = channelLimit;
|
||||
host -> incomingBandwidth = incomingBandwidth;
|
||||
@@ -103,6 +107,8 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
|
||||
host -> compressor.decompress = NULL;
|
||||
host -> compressor.destroy = NULL;
|
||||
|
||||
host -> intercept = NULL;
|
||||
|
||||
enet_list_clear (& host -> dispatchQueue);
|
||||
|
||||
for (currentPeer = host -> peers;
|
||||
@@ -135,6 +141,9 @@ enet_host_destroy (ENetHost * host)
|
||||
{
|
||||
ENetPeer * currentPeer;
|
||||
|
||||
if (host == NULL)
|
||||
return;
|
||||
|
||||
enet_socket_destroy (host -> socket);
|
||||
|
||||
for (currentPeer = host -> peers;
|
||||
|
||||
+22
-3
@@ -25,12 +25,16 @@ extern "C"
|
||||
|
||||
#define ENET_VERSION_MAJOR 1
|
||||
#define ENET_VERSION_MINOR 3
|
||||
#define ENET_VERSION_PATCH 5
|
||||
#define ENET_VERSION_PATCH 7
|
||||
#define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch))
|
||||
#define ENET_VERSION ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR, ENET_VERSION_PATCH)
|
||||
|
||||
typedef enet_uint32 ENetVersion;
|
||||
|
||||
struct _ENetHost;
|
||||
struct _ENetEvent;
|
||||
struct _ENetPacket;
|
||||
|
||||
typedef enum _ENetSocketType
|
||||
{
|
||||
ENET_SOCKET_TYPE_STREAM = 1,
|
||||
@@ -55,6 +59,13 @@ typedef enum _ENetSocketOption
|
||||
ENET_SOCKOPT_SNDTIMEO = 7
|
||||
} ENetSocketOption;
|
||||
|
||||
typedef enum _ENetSocketShutdown
|
||||
{
|
||||
ENET_SOCKET_SHUTDOWN_READ = 0,
|
||||
ENET_SOCKET_SHUTDOWN_WRITE = 1,
|
||||
ENET_SOCKET_SHUTDOWN_READ_WRITE = 2
|
||||
} ENetSocketShutdown;
|
||||
|
||||
enum
|
||||
{
|
||||
ENET_HOST_ANY = 0, /**< specifies the default server host */
|
||||
@@ -101,10 +112,12 @@ typedef enum _ENetPacketFlag
|
||||
ENET_PACKET_FLAG_NO_ALLOCATE = (1 << 2),
|
||||
/** packet will be fragmented using unreliable (instead of reliable) sends
|
||||
* if it exceeds the MTU */
|
||||
ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT = (1 << 3)
|
||||
ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT = (1 << 3),
|
||||
|
||||
/** whether the packet has been sent from all queues it has been entered into */
|
||||
ENET_PACKET_FLAG_SENT = (1<<8)
|
||||
} ENetPacketFlag;
|
||||
|
||||
struct _ENetPacket;
|
||||
typedef void (ENET_CALLBACK * ENetPacketFreeCallback) (struct _ENetPacket *);
|
||||
|
||||
/**
|
||||
@@ -133,6 +146,7 @@ typedef struct _ENetPacket
|
||||
enet_uint8 * data; /**< allocated data for packet */
|
||||
size_t dataLength; /**< length of data */
|
||||
ENetPacketFreeCallback freeCallback; /**< function to be called when the packet is no longer in use */
|
||||
void * userData; /**< application private data, may be freely modified */
|
||||
} ENetPacket;
|
||||
|
||||
typedef struct _ENetAcknowledgement
|
||||
@@ -312,6 +326,9 @@ typedef struct _ENetCompressor
|
||||
|
||||
/** Callback that computes the checksum of the data held in buffers[0:bufferCount-1] */
|
||||
typedef enet_uint32 (ENET_CALLBACK * ENetChecksumCallback) (const ENetBuffer * buffers, size_t bufferCount);
|
||||
|
||||
/** Callback for intercepting received raw UDP packets. Should return 1 to intercept, 0 to ignore, or -1 to propagate an error. */
|
||||
typedef int (ENET_CALLBACK * ENetInterceptCallback) (struct _ENetHost * host, struct _ENetEvent * event);
|
||||
|
||||
/** An ENet host for communicating with peers.
|
||||
*
|
||||
@@ -361,6 +378,7 @@ typedef struct _ENetHost
|
||||
enet_uint32 totalSentPackets; /**< total UDP packets sent, user should reset to 0 as needed to prevent overflow */
|
||||
enet_uint32 totalReceivedData; /**< total data received, user should reset to 0 as needed to prevent overflow */
|
||||
enet_uint32 totalReceivedPackets; /**< total UDP packets received, user should reset to 0 as needed to prevent overflow */
|
||||
ENetInterceptCallback intercept; /**< callback the user can set to intercept received raw UDP packets */
|
||||
} ENetHost;
|
||||
|
||||
/**
|
||||
@@ -460,6 +478,7 @@ ENET_API int enet_socket_send (ENetSocket, const ENetAddress *, const ENe
|
||||
ENET_API int enet_socket_receive (ENetSocket, ENetAddress *, ENetBuffer *, size_t);
|
||||
ENET_API int enet_socket_wait (ENetSocket, enet_uint32 *, enet_uint32);
|
||||
ENET_API int enet_socket_set_option (ENetSocket, ENetSocketOption, int);
|
||||
ENET_API int enet_socket_shutdown (ENetSocket, ENetSocketShutdown);
|
||||
ENET_API void enet_socket_destroy (ENetSocket);
|
||||
ENET_API int enet_socketset_select (ENetSocket, ENetSocketSet *, ENetSocketSet *, enet_uint32);
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ enet_packet_create (const void * data, size_t dataLength, enet_uint32 flags)
|
||||
packet -> flags = flags;
|
||||
packet -> dataLength = dataLength;
|
||||
packet -> freeCallback = NULL;
|
||||
packet -> userData = NULL;
|
||||
|
||||
return packet;
|
||||
}
|
||||
@@ -55,6 +56,9 @@ enet_packet_create (const void * data, size_t dataLength, enet_uint32 flags)
|
||||
void
|
||||
enet_packet_destroy (ENetPacket * packet)
|
||||
{
|
||||
if (packet == NULL)
|
||||
return;
|
||||
|
||||
if (packet -> freeCallback != NULL)
|
||||
(* packet -> freeCallback) (packet);
|
||||
if (! (packet -> flags & ENET_PACKET_FLAG_NO_ALLOCATE) &&
|
||||
@@ -112,7 +116,7 @@ reflect_crc (int val, int bits)
|
||||
}
|
||||
|
||||
static void
|
||||
initialize_crc32 ()
|
||||
initialize_crc32 (void)
|
||||
{
|
||||
int byte;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
the mean round trip time measured over the interval, then the throttle probability
|
||||
is decreased to limit traffic by an amount specified in the deceleration parameter, which
|
||||
is a ratio to the ENET_PEER_PACKET_THROTTLE_SCALE constant. When the throttle has
|
||||
a value of ENET_PEER_PACKET_THROTTLE_SCALE, on unreliable packets are dropped by
|
||||
a value of ENET_PEER_PACKET_THROTTLE_SCALE, no unreliable packets are dropped by
|
||||
ENet, and so 100% of all unreliable packets will be sent. When the throttle has a
|
||||
value of 0, all unreliable packets are dropped by ENet, and so 0% of all unreliable
|
||||
packets will be sent. Intermediate values for the throttle represent intermediate
|
||||
@@ -751,7 +751,6 @@ enet_peer_dispatch_incoming_unreliable_commands (ENetPeer * peer, ENetChannel *
|
||||
void
|
||||
enet_peer_dispatch_incoming_reliable_commands (ENetPeer * peer, ENetChannel * channel)
|
||||
{
|
||||
enet_uint16 oldReliableSequenceNumber = channel -> incomingReliableSequenceNumber;
|
||||
ENetListIterator currentCommand;
|
||||
|
||||
for (currentCommand = enet_list_begin (& channel -> incomingReliableCommands);
|
||||
|
||||
+51
-6
@@ -163,7 +163,11 @@ enet_protocol_remove_sent_unreliable_commands (ENetPeer * peer)
|
||||
-- outgoingCommand -> packet -> referenceCount;
|
||||
|
||||
if (outgoingCommand -> packet -> referenceCount == 0)
|
||||
enet_packet_destroy (outgoingCommand -> packet);
|
||||
{
|
||||
outgoingCommand -> packet -> flags |= ENET_PACKET_FLAG_SENT;
|
||||
|
||||
enet_packet_destroy (outgoingCommand -> packet);
|
||||
}
|
||||
}
|
||||
|
||||
enet_free (outgoingCommand);
|
||||
@@ -210,6 +214,9 @@ enet_protocol_remove_sent_reliable_command (ENetPeer * peer, enet_uint16 reliabl
|
||||
wasSent = 0;
|
||||
}
|
||||
|
||||
if (outgoingCommand == NULL)
|
||||
return ENET_PROTOCOL_COMMAND_NONE;
|
||||
|
||||
if (channelID < peer -> channelCount)
|
||||
{
|
||||
ENetChannel * channel = & peer -> channels [channelID];
|
||||
@@ -234,7 +241,11 @@ enet_protocol_remove_sent_reliable_command (ENetPeer * peer, enet_uint16 reliabl
|
||||
-- outgoingCommand -> packet -> referenceCount;
|
||||
|
||||
if (outgoingCommand -> packet -> referenceCount == 0)
|
||||
enet_packet_destroy (outgoingCommand -> packet);
|
||||
{
|
||||
outgoingCommand -> packet -> flags |= ENET_PACKET_FLAG_SENT;
|
||||
|
||||
enet_packet_destroy (outgoingCommand -> packet);
|
||||
}
|
||||
}
|
||||
|
||||
enet_free (outgoingCommand);
|
||||
@@ -382,7 +393,7 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet
|
||||
verifyCommand.verifyConnect.outgoingPeerID = ENET_HOST_TO_NET_16 (currentPeer -> incomingPeerID);
|
||||
verifyCommand.verifyConnect.incomingSessionID = incomingSessionID;
|
||||
verifyCommand.verifyConnect.outgoingSessionID = outgoingSessionID;
|
||||
verifyCommand.verifyConnect.mtu = ENET_HOST_TO_NET_16 (currentPeer -> mtu);
|
||||
verifyCommand.verifyConnect.mtu = ENET_HOST_TO_NET_32 (currentPeer -> mtu);
|
||||
verifyCommand.verifyConnect.windowSize = ENET_HOST_TO_NET_32 (windowSize);
|
||||
verifyCommand.verifyConnect.channelCount = ENET_HOST_TO_NET_32 (channelCount);
|
||||
verifyCommand.verifyConnect.incomingBandwidth = ENET_HOST_TO_NET_32 (host -> incomingBandwidth);
|
||||
@@ -739,12 +750,18 @@ enet_protocol_handle_send_unreliable_fragment (ENetHost * host, ENetPeer * peer,
|
||||
static int
|
||||
enet_protocol_handle_ping (ENetHost * host, ENetPeer * peer, const ENetProtocol * command)
|
||||
{
|
||||
if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
enet_protocol_handle_bandwidth_limit (ENetHost * host, ENetPeer * peer, const ENetProtocol * command)
|
||||
{
|
||||
if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)
|
||||
return -1;
|
||||
|
||||
peer -> incomingBandwidth = ENET_NET_TO_HOST_32 (command -> bandwidthLimit.incomingBandwidth);
|
||||
peer -> outgoingBandwidth = ENET_NET_TO_HOST_32 (command -> bandwidthLimit.outgoingBandwidth);
|
||||
|
||||
@@ -766,6 +783,9 @@ enet_protocol_handle_bandwidth_limit (ENetHost * host, ENetPeer * peer, const EN
|
||||
static int
|
||||
enet_protocol_handle_throttle_configure (ENetHost * host, ENetPeer * peer, const ENetProtocol * command)
|
||||
{
|
||||
if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)
|
||||
return -1;
|
||||
|
||||
peer -> packetThrottleInterval = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleInterval);
|
||||
peer -> packetThrottleAcceleration = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleAcceleration);
|
||||
peer -> packetThrottleDeceleration = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleDeceleration);
|
||||
@@ -776,7 +796,7 @@ enet_protocol_handle_throttle_configure (ENetHost * host, ENetPeer * peer, const
|
||||
static int
|
||||
enet_protocol_handle_disconnect (ENetHost * host, ENetPeer * peer, const ENetProtocol * command)
|
||||
{
|
||||
if (peer -> state == ENET_PEER_STATE_ZOMBIE || peer -> state == ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT)
|
||||
if (peer -> state == ENET_PEER_STATE_DISCONNECTED || peer -> state == ENET_PEER_STATE_ZOMBIE || peer -> state == ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT)
|
||||
return 0;
|
||||
|
||||
enet_peer_reset_queues (peer);
|
||||
@@ -810,6 +830,9 @@ enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer *
|
||||
receivedReliableSequenceNumber;
|
||||
ENetProtocolCommand commandNumber;
|
||||
|
||||
if (peer -> state == ENET_PEER_STATE_DISCONNECTED || peer -> state == ENET_PEER_STATE_ZOMBIE)
|
||||
return 0;
|
||||
|
||||
receivedSentTime = ENET_NET_TO_HOST_16 (command -> acknowledge.receivedSentTime);
|
||||
receivedSentTime |= host -> serviceTime & 0xFFFF0000;
|
||||
if ((receivedSentTime & 0x8000) > (host -> serviceTime & 0x8000))
|
||||
@@ -1062,7 +1085,7 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
|
||||
|
||||
command -> header.reliableSequenceNumber = ENET_NET_TO_HOST_16 (command -> header.reliableSequenceNumber);
|
||||
|
||||
switch (command -> header.command & ENET_PROTOCOL_COMMAND_MASK)
|
||||
switch (commandNumber)
|
||||
{
|
||||
case ENET_PROTOCOL_COMMAND_ACKNOWLEDGE:
|
||||
if (enet_protocol_handle_acknowledge (host, event, peer, command))
|
||||
@@ -1070,6 +1093,8 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
|
||||
break;
|
||||
|
||||
case ENET_PROTOCOL_COMMAND_CONNECT:
|
||||
if (peer != NULL)
|
||||
goto commandError;
|
||||
peer = enet_protocol_handle_connect (host, header, command);
|
||||
if (peer == NULL)
|
||||
goto commandError;
|
||||
@@ -1143,6 +1168,8 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
|
||||
{
|
||||
case ENET_PEER_STATE_DISCONNECTING:
|
||||
case ENET_PEER_STATE_ACKNOWLEDGING_CONNECT:
|
||||
case ENET_PEER_STATE_DISCONNECTED:
|
||||
case ENET_PEER_STATE_ZOMBIE:
|
||||
break;
|
||||
|
||||
case ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT:
|
||||
@@ -1191,7 +1218,25 @@ enet_protocol_receive_incoming_commands (ENetHost * host, ENetEvent * event)
|
||||
|
||||
host -> totalReceivedData += receivedLength;
|
||||
host -> totalReceivedPackets ++;
|
||||
|
||||
|
||||
if (host -> intercept != NULL)
|
||||
{
|
||||
switch (host -> intercept (host, event))
|
||||
{
|
||||
case 1:
|
||||
if (event != NULL && event -> type != ENET_EVENT_TYPE_NONE)
|
||||
return 1;
|
||||
|
||||
continue;
|
||||
|
||||
case -1:
|
||||
return -1;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (enet_protocol_handle_incoming_commands (host, event))
|
||||
{
|
||||
case 1:
|
||||
|
||||
@@ -18,12 +18,29 @@
|
||||
#define ENET_BUILDING_LIB 1
|
||||
#include "enet/enet.h"
|
||||
|
||||
#ifdef HAS_FCNTL
|
||||
#include <fcntl.h>
|
||||
#ifdef __APPLE__
|
||||
#ifdef HAS_POLL
|
||||
#undef HAS_POLL
|
||||
#endif
|
||||
#ifndef HAS_FCNTL
|
||||
#define HAS_FCNTL 1
|
||||
#endif
|
||||
#ifndef HAS_INET_PTON
|
||||
#define HAS_INET_PTON 1
|
||||
#endif
|
||||
#ifndef HAS_INET_NTOP
|
||||
#define HAS_INET_NTOP 1
|
||||
#endif
|
||||
#ifndef HAS_MSGHDR_FLAGS
|
||||
#define HAS_MSGHDR_FLAGS 1
|
||||
#endif
|
||||
#ifndef HAS_SOCKLEN_T
|
||||
#define HAS_SOCKLEN_T 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#undef HAS_POLL
|
||||
#ifdef HAS_FCNTL
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAS_POLL
|
||||
@@ -237,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));
|
||||
|
||||
@@ -244,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
|
||||
@@ -270,10 +292,17 @@ 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)
|
||||
{
|
||||
close (socket);
|
||||
if (socket != -1)
|
||||
close (socket);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -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 () != WSAEWOULDBLOCK)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ENetSocket
|
||||
@@ -217,10 +222,17 @@ 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)
|
||||
{
|
||||
closesocket (socket);
|
||||
if (socket != INVALID_SOCKET)
|
||||
closesocket (socket);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user