Skip to content

Commit 2a567b0

Browse files
committed
Set socket option IPV6_V6ONLY before bind()
1 parent 2b52599 commit 2a567b0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

host.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
4949
memset (host -> peers, 0, peerCount * sizeof (ENetPeer));
5050

5151
host -> socket = enet_socket_create (ENET_SOCKET_TYPE_DATAGRAM);
52+
if( host -> socket > ENET_SOCKET_NULL )
53+
enet_socket_set_option (host -> socket, ENET_SOCKOPT_IPV6_V6ONLY, 0);
5254
if (host -> socket == ENET_SOCKET_NULL || (address != NULL && enet_socket_bind (host -> socket, address) < 0))
5355
{
5456
if (host -> socket != ENET_SOCKET_NULL)
@@ -64,7 +66,6 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
6466
enet_socket_set_option (host -> socket, ENET_SOCKOPT_BROADCAST, 1);
6567
enet_socket_set_option (host -> socket, ENET_SOCKOPT_RCVBUF, ENET_HOST_RECEIVE_BUFFER_SIZE);
6668
enet_socket_set_option (host -> socket, ENET_SOCKOPT_SNDBUF, ENET_HOST_SEND_BUFFER_SIZE);
67-
enet_socket_set_option (host -> socket, ENET_SOCKOPT_IPV6_V6ONLY, 0);
6869

6970

7071
if (address != NULL && enet_socket_get_address (host -> socket, & host -> address) < 0)

0 commit comments

Comments
 (0)