From fd6b4cc1dbc7dd3fa7fabff5e165caf2db54ef20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 17 Dec 2013 13:59:01 +0100 Subject: [PATCH] Add forgotten SO_REUSEADDR option --- library/net.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/net.c b/library/net.c index f00e8ef81..19f699d50 100644 --- a/library/net.c +++ b/library/net.c @@ -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 ) { #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; char port_str[6]; @@ -260,6 +260,10 @@ int net_bind( int *fd, const char *bind_ip, int port ) continue; } + n = 1; + setsockopt( *fd, SOL_SOCKET, SO_REUSEADDR, + (const char *) &n, sizeof( n ) ); + if( bind( *fd, cur->ai_addr, cur->ai_addrlen ) != 0 ) { close( *fd );