Make socket reusable

This commit is contained in:
Yamagi Burmeister 2011-10-17 10:07:50 +00:00
parent 8f04a73f86
commit 0a9585ee1b

View file

@ -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));