Jump to content
  • Advertisement

Archived

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

ftsf

SDLNet Server

This topic is 5805 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!