medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 4c1cc15a288970c3987576aa75a4e42b3f3ec745
parent 470b9a0b4da5ab35b1f68d7a15c878aa2711e8dc
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Thu Dec 29 13:57:18 +0200

Call bind when creating UDP sockets

Diffstat:
platform_network.h | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/platform_network.h b/platform_network.h @@ -42,6 +42,18 @@ inline void sock_init( Socket * sock, IPvX ipvx, TransportProtocol transport, No FATAL( "socket" ); } + if( transport == NET_UDP ) { + // TODO IPv6 + sockaddr_in my_addr; + my_addr.sin_family = AF_INET; + my_addr.sin_port = 0; + my_addr.sin_addr.s_addr = htonl( INADDR_ANY ); + int ok = bind( sock->fd, ( sockaddr * ) &my_addr, sizeof( my_addr ) ); + if( ok == SOCKET_ERROR ) { + FATAL( "bind" ); + } + } + if( nonblocking == NET_NONBLOCKING ) { sock_fd_nonblocking( sock->fd ); }