mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-31 13:20:34 +00:00
Make socket reusable
This commit is contained in:
parent
8f04a73f86
commit
0a9585ee1b
1 changed files with 9 additions and 2 deletions
|
@ -851,8 +851,7 @@ NET_Socket ( char *net_interface, int port, netsrc_t type, int family )
|
|||
if (family == AF_INET)
|
||||
{
|
||||
/* make it broadcast capable */
|
||||
if (setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i,
|
||||
sizeof(i)) == -1)
|
||||
if (setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i)) == -1)
|
||||
{
|
||||
Com_Printf("ERROR: NET_Socket: setsockopt SO_BROADCAST:%s\n",
|
||||
NET_ErrorString());
|
||||
|
@ -860,6 +859,14 @@ NET_Socket ( char *net_interface, int port, netsrc_t type, int family )
|
|||
}
|
||||
}
|
||||
|
||||
/* make it reusable */
|
||||
if (setsockopt(newsocket, SOL_SOCKET, SO_REUSEADDR, (char *)&i, sizeof(i)) == -1)
|
||||
{
|
||||
Com_Printf("ERROR: NET_Socket: setsockopt SO_REUSEADDR:%s\n",
|
||||
NET_ErrorString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bind(newsocket, ai->ai_addr, ai->ai_addrlen) < 0)
|
||||
{
|
||||
Com_Printf("NET_Socket: bind: %s\n", strerror(errno));
|
||||
|
|
Loading…
Reference in a new issue