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.
diff --git a/programs/test/udp_proxy.c b/programs/test/udp_proxy.c
index 7360d8a..76e3b31 100644
--- a/programs/test/udp_proxy.c
+++ b/programs/test/udp_proxy.c
@@ -533,6 +533,8 @@
* 2. Wait until a client connects
*/
accept:
+ mbedtls_net_free( &client_fd );
+
mbedtls_printf( " . Waiting for a remote connection ..." );
fflush( stdout );
@@ -544,20 +546,6 @@
}
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" );
/*
* 3. Forward packets forever (kill the process to terminate it)