Advertisement

Win32 networking & threading

Started by May 26, 2003 02:23 AM
1 comment, last by Structural 21 years, 8 months ago
Lo, At the moment I'm working on my first networking module and I have a question about the usage of threads in such a module. I'm using TCP for this whole thing as I want to guarantee the arrival of the packets. At the moment I have threaded the acceptance function (to accept new connections) and the receive function (to read all sockets). The latter function reads ALL active sockets in the same thread. My question is: would it be wise to create MULTIPLE threads that read the sockets? So, one thread for each socket? I don't want the stuff to block when a client goes tits up. Also, when sending data, do I want to do this in seperate threads? So, one thread for each socket to send data... Thanks for any answers and tips [edited by - Structural on May 26, 2003 3:24:46 AM]
STOP THE PLANET!! I WANT TO GET OFF!!
How many sockets will your application be using at once?

If you create a new thread for every socket, then you should not be using too many sockets at once, since threads are expensive.

If your application must handle many sockets at once (I would say more than about 20 or 30), then I recommend that you use asynchronous sockets.
Advertisement
What I/O model does the program utilize?

Kuphryn

This topic is closed to new replies.

Advertisement