Check setsockopt() return value in net_bind()

This commit is contained in:
Paul Bakker 2014-04-17 12:43:05 +02:00
parent 3d8fb63e11
commit 874bd64b28

View File

@ -281,8 +281,13 @@ int net_bind( int *fd, const char *bind_ip, int port )
} }
n = 1; n = 1;
setsockopt( *fd, SOL_SOCKET, SO_REUSEADDR, if( setsockopt( *fd, SOL_SOCKET, SO_REUSEADDR,
(const char *) &n, sizeof( n ) ); (const char *) &n, sizeof( n ) ) != 0 )
{
close( *fd );
ret = POLARSSL_ERR_NET_SOCKET_FAILED;
continue;
}
if( bind( *fd, cur->ai_addr, cur->ai_addrlen ) != 0 ) if( bind( *fd, cur->ai_addr, cur->ai_addrlen ) != 0 )
{ {