commit ab219a2e7d8fbacb2cbe283f8c4e100dc84308ce parent eb9495167c070c333a59b3719b23496812599d90 Author: Michael Savage <mikejsavage@gmail.com> Date: Tue Sep 5 19:44:26 +0300 OSX fix Diffstat:
platform_network.cc | | | 6 | ++++++ |
unix_network.cc | | | 10 | ++++++++++ |
win32_network.cc | | | 2 | ++ |
diff --git a/platform_network.cc b/platform_network.cc @@ -9,6 +9,7 @@ struct sockaddr_storage; static NetAddress sockaddr_to_netaddress( const struct sockaddr_storage & ss ); static struct sockaddr_storage netaddress_to_sockaddr( const NetAddress & addr ); +static void setsockoptone( OSSocket fd, int level, int opt ); #if PLATFORM_WINDOWS #include "win32_network.cc" @@ -117,6 +118,9 @@ UDPSocket net_new_udp( NonblockingBool nonblocking, u16 port ) { setsockoptone( sock.ipv6, IPPROTO_IPV6, IPV6_V6ONLY ); } + platform_init_sock( sock.ipv4 ); + platform_init_sock( sock.ipv6 ); + { sockaddr_in my_addr4; my_addr4.sin_family = AF_INET; @@ -188,6 +192,8 @@ bool net_new_tcp( TCPSocket * sock, const NetAddress & addr, NonblockingBool non make_socket_nonblocking( sock->fd ); } + platform_init_sock( sock->fd ); + return true; } diff --git a/unix_network.cc b/unix_network.cc @@ -12,7 +12,11 @@ #define closesocket close +#if PLATFORM_OSX +static int NET_SEND_FLAGS = 0; +#else static int NET_SEND_FLAGS = MSG_NOSIGNAL; +#endif void net_init() { } void net_term() { } @@ -24,6 +28,12 @@ static void make_socket_nonblocking( int fd ) { if( ok == -1 ) FATAL( "fcntl F_SETFL" ); } +static void platform_init_sock( int fd ) { +#if PLATFORM_OSX + setsockoptone( fd, SOL_SOCKET, SO_NOSIGPIPE ); +#endif +} + bool net_tryrecv( UDPSocket sock, void * buf, size_t len, NetAddress * addr, size_t * bytes_received ) { struct sockaddr_storage sa; diff --git a/win32_network.cc b/win32_network.cc @@ -24,6 +24,8 @@ static void make_socket_nonblocking( SOCKET fd ) { } } +static void platform_init_sock( SOCKET fd ) { } + bool net_tryrecv( UDPSocket sock, void * buf, size_t len, NetAddress * addr, size_t * bytes_received ) { struct sockaddr_storage sa;