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 eb3c8e4
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;

Check warning on line 886 in toxcore/network.c

View check run for this annotation

Codecov / codecov/patch

toxcore/network.c#L886

Added line #L886 was not covered by tests
}

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

return true;
}

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

0 comments on commit eb3c8e4

Please sign in to comment.