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 cfc129e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion toxcore/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,14 @@ 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;
bool ret = net_setsockopt(ns, sock, SOL_SOCKET, SO_REUSEADDR, &set, sizeof(set)) == 0;
if (!ret) {
return ret;
}
#ifdef OS_WIN32
ret = net_setsockopt(ns, sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, &set, sizeof(set)) == 0;
#endif
return ret;
}

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

0 comments on commit cfc129e

Please sign in to comment.