Jump to content
  • Advertisement
Sign in to follow this  
MarkSponge

Winsock Server/Client Connections

This topic is 4847 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 have wrote a basic Client / Server application in C++ with the server updating a MySQL database. I have this app working with a single user connected. I am updating it to accept multiple connections. My question is when the server is waiting/listening to a socket for new connectings my server stops processing data from the client already connected. Could someone show me the logic for a server that can listen for new connections and still continue to run through the program? I have looked through the forum FAQ and done lots of Googleing to no result. There are lots of simple client/server examples out there but none show a solution to my problem. Thanks in advance, MarkSponge

Share this post


Link to post
Share on other sites
Advertisement
Well, I cannot really give you an example. And I use MFC for sockets. But I would suggest using threads for each client that is connected. There are plenty of places on the internet that talk about client/server applications that use threads for multiple connections with clients. Try googling for threads, or visit CodeProject.com. =) Hope that helps.

Share this post


Link to post
Share on other sites
I went the single threaded route, and used non-blocking IO.

Here is my class set, along with a main.cpp file to demonstrate how it handles multiple connects/sends/receives "at the same time".

http://ada.podzone.org/taby/sock.zip

To run the server, simply start the executable.
To run a client, hold shift while starting the executable. You can run many clients at once obviously.

Share this post


Link to post
Share on other sites
Actually multiple threads performance wise is just good in a multi core system, and even with a multicore system you want to keep the amount of working threads as close to the number of cores as possible.
So for a single core system you'll probably be better off, like taby said, just using non-blocking IO, with the select() model, WSAAsyncSelect() model, WSAEventSelect model, the Overlapped model or the, ever so famous for it's performance, IOCP model.
You can read further details about these models on "Network Programming for Microsoft Windows" or searching the web for server models, these names are bound to come up.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!