summaryrefslogtreecommitdiffhomepage
path: root/host.c
diff options
context:
space:
mode:
Diffstat (limited to 'host.c')
-rw-r--r--host.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/host.c b/host.c
index 9bab1a8..30eaded 100644
--- a/host.c
+++ b/host.c
@@ -36,9 +36,12 @@ enet_host_create (const ENetAddress * address, size_t peerCount, enet_uint32 inc
host -> peers = (ENetPeer *) enet_malloc (peerCount * sizeof (ENetPeer));
memset (host -> peers, 0, peerCount * sizeof (ENetPeer));
- host -> socket = enet_socket_create (ENET_SOCKET_TYPE_DATAGRAM, address);
- if (host -> socket == ENET_SOCKET_NULL)
+ host -> socket = enet_socket_create (ENET_SOCKET_TYPE_DATAGRAM);
+ if (host -> socket == ENET_SOCKET_NULL || (address != NULL && enet_socket_bind (host -> socket, address) < 0))
{
+ if (host -> socket != ENET_SOCKET_NULL)
+ enet_socket_destroy (host -> socket);
+
enet_free (host -> peers);
enet_free (host);