Skip to content

Commit

Permalink
Explicitly disable IPV6_V6ONLY flag.
Browse files Browse the repository at this point in the history
(It defaults to 1 for WinSock and 0 most other places.)

We try to do this no matter what, and we don't care if it fails; in case of
failure, it was either applied to a non-IPv6 socket where it would be
meaningless, or we're just going to have to live with what we got anyhow.

Reference Issue #84.
Reference Issue #58.
  • Loading branch information
icculus committed Oct 22, 2023
1 parent 57359d2 commit 402fe23
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/SDL_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,9 @@ SDLNet_Server *SDLNet_CreateServer(SDLNet_Address *addr, Uint16 port)
return NULL;
}

int zero = 0;
setsockopt(server->handle, SOL_IPV6, IPV6_V6ONLY, &zero, sizeof (zero)); // if this fails, oh well.

int rc = bind(server->handle, addrwithport->ai_addr, addrwithport->ai_addrlen);
freeaddrinfo(addrwithport);

Expand Down Expand Up @@ -1284,6 +1287,9 @@ SDLNet_DatagramSocket *SDLNet_CreateDatagramSocket(SDLNet_Address *addr, Uint16
return NULL;
}

int zero = 0;
setsockopt(sock->handle, SOL_IPV6, IPV6_V6ONLY, &zero, sizeof (zero)); // if this fails, oh well.

const int rc = bind(sock->handle, addrwithport->ai_addr, addrwithport->ai_addrlen);
freeaddrinfo(addrwithport);

Expand Down

0 comments on commit 402fe23

Please sign in to comment.