From f7c59df2fb23154b871535f0146ee2e031c1e3ec Mon Sep 17 00:00:00 2001 From: Dan Bechard Date: Sat, 7 Sep 2024 01:45:56 -0400 Subject: [PATCH 1/2] Print warning when disabling SIO_UDP_CONNRESET fails. Signed-off-by: Dan Bechard --- netcode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/netcode.c b/netcode.c index 58a5fcf..9c5c8f6 100755 --- a/netcode.c +++ b/netcode.c @@ -476,7 +476,10 @@ int netcode_socket_create( struct netcode_socket_t * s, struct netcode_address_t #define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR, 12) BOOL bNewBehavior = FALSE; DWORD dwBytesReturned = 0; - WSAIoctl( s->handle, SIO_UDP_CONNRESET, &bNewBehavior, sizeof(bNewBehavior), NULL, 0, &dwBytesReturned, NULL, NULL ); + if ( WSAIoctl( s->handle, SIO_UDP_CONNRESET, &bNewBehavior, sizeof(bNewBehavior), NULL, 0, &dwBytesReturned, NULL, NULL ) != 0 ) + { + netcode_printf( NETCODE_LOG_LEVEL_ERROR, "warning: failed to disable UDP port unreachable messages on socket\n" ); + } #endif // force IPv6 only if necessary From 98e54335fd3b174d96c6889ec3004d2a65bfefdc Mon Sep 17 00:00:00 2001 From: Dan Bechard Date: Mon, 9 Sep 2024 13:16:57 -0400 Subject: [PATCH 2/2] Make connreset failure an error Signed-off-by: Dan Bechard --- netcode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/netcode.c b/netcode.c index 9c5c8f6..a930634 100755 --- a/netcode.c +++ b/netcode.c @@ -426,6 +426,7 @@ struct netcode_socket_holder_t #define NETCODE_SOCKET_ERROR_BIND_IPV6_FAILED 7 #define NETCODE_SOCKET_ERROR_GET_SOCKNAME_IPV4_FAILED 8 #define NETCODE_SOCKET_ERROR_GET_SOCKNAME_IPV6_FAILED 7 +#define NETCODE_SOCKET_ERROR_DISABLE_UDP_PORT_CONNRESET_FAILED 10 void netcode_socket_destroy( struct netcode_socket_t * socket ) { @@ -478,7 +479,9 @@ int netcode_socket_create( struct netcode_socket_t * s, struct netcode_address_t DWORD dwBytesReturned = 0; if ( WSAIoctl( s->handle, SIO_UDP_CONNRESET, &bNewBehavior, sizeof(bNewBehavior), NULL, 0, &dwBytesReturned, NULL, NULL ) != 0 ) { - netcode_printf( NETCODE_LOG_LEVEL_ERROR, "warning: failed to disable UDP port unreachable messages on socket\n" ); + netcode_printf( NETCODE_LOG_LEVEL_ERROR, "error: failed to disable UDP CONNRESET (port unreachable) message reporting on socket\n" ); + netcode_socket_destroy( s ); + return NETCODE_SOCKET_ERROR_DISABLE_UDP_PORT_CONNRESET_FAILED; } #endif