Pros and Cons of blocking versus non-blocking sockets?
OK, normally I use blocking sockets because they reduce processor overhead when dealing with only a small number of connections (1-5), but now I am going to be working with an application that will have potentially hundreds or thousands of simultaneous connections. The method I use right now is to have one thread listen() and accept() connections and then spawn a new thread for each client. This works great in my at most 5 clients applications, but I am wondering how well it will do with hundreds. I only expect each connection to be transferring about 4KB per second, at most 10 times per second. I was thinking of using select to check for data and Sleep(0) to pass control if there is none.
I would prefer to stick with a multithreaded model if possible, since it scales better, but I'm open to suggestion.