Archived

This topic is now archived and is closed to further replies.

ftsf

SDLNet Server

Recommended Posts

i''m trying to make a server for my network game, but the server only registers the first client, all clients after that are ignored until the subsequent client quits. is this a problem with my code? or something with SDLNet, or could it be because i am running all the clients on the same computer? while(true) { if(nClients < nMaxClients) { // search for a free client for(x = 0; x <= nMaxClients; x++) { if(client[x].open == false) break; } client[x].sock = SDLNet_TCP_Accept(listeningSocket); if(client[x].sock != NULL) { client[x].open = true; nClients++; } } // Read client messages for(x = 0; x < nMaxClients; x++) { if(client[x].open == true) { unsigned short cmd; int len = SDLNet_TCP_Recv(client[x].sock, &cmd, 2); if(len) { if(cmd == SP_NAME) { SDLNet_TCP_Recv(client[x].sock, client[x].name, 15); } else if(cmd == SP_QUIT) { SDLNet_TCP_Close(client[x].sock); client[x].open = false; nClients--; } } } } }

Share this post


Link to post
Share on other sites