ServerFrameCounter++;
}
+void ExitNetworkServer(int exit_value)
+{
+ Error(ERR_NETWORK_SERVER, "exiting network server");
+
+ exit(exit_value);
+}
+
/* the following is not used for a standalone server;
the pointer points to an integer containing the port-number */
int NetworkServerThread(void *ptr)
void NetworkServer(int port, int serveronly)
{
- int sl;
struct NetworkServerPlayerInfo *player;
int r;
unsigned int len;
if (port == 0)
port = DEFAULT_SERVER_PORT;
+ // if only running the network server, exit on Ctrl-C
+ if (serveronly)
+ signal(SIGINT, ExitNetworkServer);
+
if (!serveronly)
onceonly = 1;
for (player = first_player; player; player = player->next)
flushuser(player);
- if ((sl = SDLNet_CheckSockets(fds, 500000)) < 1)
- {
- Error(ERR_NETWORK_SERVER, "SDLNet_CheckSockets failed: %s",
- SDLNet_GetError());
- perror("SDLNet_CheckSockets");
- }
-
- if (sl < 0)
- continue;
-
- if (sl == 0)
+ // wait for 100 ms for activity on open network sockets
+ if (SDLNet_CheckSockets(fds, 100) < 1)
continue;
/* accept incoming connections */