summaryrefslogtreecommitdiffhomepage
path: root/host.c
diff options
context:
space:
mode:
authoreihrul <eihrul>2008-09-15 23:11:22 +0000
committereihrul <eihrul>2008-09-15 23:11:22 +0000
commitb846c47521bcf2978bf9f6c3a39e0e8a324664be (patch)
tree8faa2e1b7ec3d8fd8e9a18b15a21bd2c3d1eb31d /host.c
parent6cf5ada45ceaff7c56a413b9c14d602a49d1c975 (diff)
downloadenet-b846c47521bcf2978bf9f6c3a39e0e8a324664be.tar.gz
enet-b846c47521bcf2978bf9f6c3a39e0e8a324664be.zip
added miscellaneous updates for broadcasting
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);