Simplify net_accept() with UDP sockets

This is made possible by the new API where net_accept() gets a pointer to
bind_ctx, so it can update it.
This commit is contained in:
Manuel Pégourié-Gonnard 2015-07-01 01:28:24 +02:00
parent db2468d7aa
commit abc729e664
6 changed files with 26 additions and 48 deletions

View file

@ -533,6 +533,8 @@ int main( int argc, char *argv[] )
* 2. Wait until a client connects
*/
accept:
mbedtls_net_free( &client_fd );
mbedtls_printf( " . Waiting for a remote connection ..." );
fflush( stdout );
@ -543,20 +545,6 @@ accept:
goto exit;
}
mbedtls_printf( " ok\n" );
fflush( stdout );
mbedtls_printf( " . Re-bind on UDP/%s/%s ...",
opt.listen_addr, opt.listen_port );
fflush( stdout );
if( ( ret = mbedtls_net_bind( &listen_fd, opt.listen_addr, opt.listen_port,
MBEDTLS_NET_PROTO_UDP ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_net_bind returned %d\n\n", ret );
goto exit;
}
mbedtls_printf( " ok\n" );
/*