Jump to content
  • Advertisement


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


SDLNet Server

This topic is 5904 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

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!