SDL_net: net: Mark bind()able sockets as SO_REUSEADDR=1.

From fbb92390211e3b0e7d8e7ea0f58df0f8cb7937fc Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Wed, 6 Aug 2025 23:42:55 -0400
Subject: [PATCH] net: Mark bind()able sockets as SO_REUSEADDR=1.

Fixes #88.
---
 src/SDL_net.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/SDL_net.c b/src/SDL_net.c
index 80a4b92..a8ab9fc 100644
--- a/src/SDL_net.c
+++ b/src/SDL_net.c
@@ -990,11 +990,13 @@ NET_Server *NET_CreateServer(NET_Address *addr, Uint16 port)
             goto failed;
         }
 
+        const int one = 1;
         if (ainfo->ai_family == AF_INET6) {
-            int one = 1;
             setsockopt(handle, IPPROTO_IPV6, IPV6_V6ONLY, (const char *) &one, sizeof (one));  // if this fails, oh well.
         }
 
+        setsockopt(handle, SOL_SOCKET, SO_REUSEADDR, &one, sizeof (one));
+
         int rc = bind(handle, ainfo->ai_addr, (SockLen) ainfo->ai_addrlen);
         if (rc == SOCKET_ERROR) {
             const int err = LastSocketError();
@@ -1405,11 +1407,13 @@ for (struct addrinfo *i = addrwithport; i != NULL; i = i->ai_next) {
             goto failed;
         }
 
+        const int one = 1;
         if (ainfo->ai_family == AF_INET6) {
-            int one = 1;
             setsockopt(handle, IPPROTO_IPV6, IPV6_V6ONLY, (const char *) &one, sizeof (one));  // if this fails, oh well.
         }
 
+        setsockopt(handle, SOL_SOCKET, SO_REUSEADDR, &one, sizeof (one));
+
         const int rc = bind(handle, ainfo->ai_addr, (SockLen) ainfo->ai_addrlen);
         if (rc == SOCKET_ERROR) {
             const int err = LastSocketError();