mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-25 09:02:48 +00:00
Add forgotten SO_REUSEADDR option
This commit is contained in:
parent
767f02cf6e
commit
fd6b4cc1db
@ -229,7 +229,7 @@ int net_connect( int *fd, const char *host, int port )
|
|||||||
int net_bind( int *fd, const char *bind_ip, int port )
|
int net_bind( int *fd, const char *bind_ip, int port )
|
||||||
{
|
{
|
||||||
#if defined(POLARSSL_HAVE_IPV6)
|
#if defined(POLARSSL_HAVE_IPV6)
|
||||||
int ret = POLARSSL_ERR_NET_UNKNOWN_HOST;
|
int n, ret = POLARSSL_ERR_NET_UNKNOWN_HOST;
|
||||||
struct addrinfo hints, *addr_list, *cur;
|
struct addrinfo hints, *addr_list, *cur;
|
||||||
char port_str[6];
|
char port_str[6];
|
||||||
|
|
||||||
@ -260,6 +260,10 @@ int net_bind( int *fd, const char *bind_ip, int port )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n = 1;
|
||||||
|
setsockopt( *fd, SOL_SOCKET, SO_REUSEADDR,
|
||||||
|
(const char *) &n, sizeof( n ) );
|
||||||
|
|
||||||
if( bind( *fd, cur->ai_addr, cur->ai_addrlen ) != 0 )
|
if( bind( *fd, cur->ai_addr, cur->ai_addrlen ) != 0 )
|
||||||
{
|
{
|
||||||
close( *fd );
|
close( *fd );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user