added some missing error handling and more detailed error messages
authorHolger Schemel <info@artsoft.org>
Thu, 31 May 2018 11:26:51 +0000 (13:26 +0200)
committerHolger Schemel <info@artsoft.org>
Mon, 18 Jun 2018 17:47:31 +0000 (19:47 +0200)
src/netserv.c

index 7c38ceed788b44a2f5921dc6a9c011c2a134cc73..547c2c9141a312b5f121c5539b9f2715fddf3f15 100644 (file)
@@ -483,14 +483,20 @@ void NetworkServer(int port, int serveronly)
 #endif
 
   if (SDLNet_ResolveHost(&ip, NULL, port) == -1)
-    Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_ResolveHost() failed");
+    Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_ResolveHost() failed: %s",
+          SDLNet_GetError());
 
-  lfd = SDLNet_TCP_Open(&ip);
-  if (!lfd)
-    Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_TCP_Open() failed");
+  if ((fds = SDLNet_AllocSocketSet(MAX_PLAYERS + 1)) == NULL)
+    Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_AllocSocketSet() failed: %s"),
+      SDLNet_GetError();
 
-  fds = SDLNet_AllocSocketSet(MAX_PLAYERS+1);
-  SDLNet_TCP_AddSocket(fds, lfd);
+  if ((lfd = SDLNet_TCP_Open(&ip)) == NULL)
+    Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_TCP_Open() failed: %s"),
+      SDLNet_GetError();
+
+  if (SDLNet_TCP_AddSocket(fds, lfd) == -1)
+    Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_TCP_AddSocket() failed: %s"),
+      SDLNet_GetError();
 
   if (options.verbose)
   {