Skip to content

Commit

Permalink
fix: windows use of REUSEADDR
Browse files Browse the repository at this point in the history
  • Loading branch information
Green-Sky committed Nov 10, 2024
1 parent 3acef4b commit 1310df4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion toxcore/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,17 @@ bool set_socket_nosigpipe(const Network *ns, Socket sock)
bool set_socket_reuseaddr(const Network *ns, Socket sock)
{
int set = 1;
return net_setsockopt(ns, sock, SOL_SOCKET, SO_REUSEADDR, &set, sizeof(set)) == 0;
if (net_setsockopt(ns, sock, SOL_SOCKET, SO_REUSEADDR, &set, sizeof(set)) != 0) {
return false;
}

#ifdef OS_WIN32
if (net_setsockopt(ns, sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, &set, sizeof(set)) != 0) {
return false;
}
#endif

return true;
}

bool set_socket_dualstack(const Network *ns, Socket sock)
Expand Down

0 comments on commit 1310df4

Please sign in to comment.