mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-21 21:36:21 +01:00
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:
parent
db2468d7aa
commit
abc729e664
6 changed files with 26 additions and 48 deletions
|
|
@ -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" );
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue