mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
engine: common: add function NET_MakeSocketReuseAddr
This commit is contained in:
committed by
Alibek Omarov
parent
a60d0d142d
commit
e808038fee
@@ -169,6 +169,12 @@ qboolean NET_MakeSocketNonBlocking( int socket_fd )
|
||||
return true;
|
||||
}
|
||||
|
||||
qboolean NET_MakeSocketReuseAddr( int socket_fd )
|
||||
{
|
||||
uint opt = 1;
|
||||
return !NET_IsSocketError( setsockopt( socket_fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof( opt )));
|
||||
}
|
||||
|
||||
void NET_NetadrToIP6Bytes( uint8_t *ip6, const netadr_t *adr )
|
||||
{
|
||||
memcpy( &ip6[0], adr->ip6_0, 2 );
|
||||
@@ -1609,7 +1615,7 @@ static int NET_IPSocket( const char *net_iface, int port, int family )
|
||||
Con_DPrintf( S_WARN "%s: port: %d setsockopt SO_BROADCAST: %s\n", __func__, port, NET_ErrorString( ));
|
||||
}
|
||||
|
||||
if( NET_IsSocketError( setsockopt( net_socket, SOL_SOCKET, SO_REUSEADDR, (const char *)&optval, sizeof( optval ))))
|
||||
if( !NET_MakeSocketReuseAddr( net_socket ))
|
||||
{
|
||||
Con_DPrintf( S_WARN "%s: port: %d setsockopt SO_REUSEADDR: %s\n", __func__, port, NET_ErrorString( ));
|
||||
closesocket( net_socket );
|
||||
|
||||
@@ -77,6 +77,7 @@ void NET_NetadrToIP6Bytes( uint8_t *ip6, const netadr_t *adr );
|
||||
qboolean NET_IsSocketError( int retval );
|
||||
qboolean NET_IsSocketValid( int socket );
|
||||
qboolean NET_MakeSocketNonBlocking( int socket_fd );
|
||||
qboolean NET_MakeSocketReuseAddr( int socket_fd );
|
||||
|
||||
static inline qboolean NET_IsLocalAddress( netadr_t adr )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user