Skip to main content
10 events
when toggle format what by license comment
Oct 31, 2013 at 15:11 comment added Panda Pajama @Grimshaw: While possible, mixing select() with blocking sockets is not usually a good idea. The network situation may change between your select() call and your IO call, and your IO call may block anyways. As a rule of thumb, if you're going to be using polling, you should set your sockets to non-blocking. Hope it helps!
Oct 31, 2013 at 15:00 comment added Grimshaw @PandaPajama "And how does each thread service N clients?" - to answer on that, there is in every major OS (at least) a feature called socket selector, which allows you to coordinate a set of blocking sockets simultaneously. hope it helps!
Oct 31, 2013 at 14:58 comment added Grimshaw My comment was to the first version of your answer, in the meanwhile, you edited and corrected it, forget what I said :D
Oct 31, 2013 at 14:42 comment added Panda Pajama @Grimshaw: And how does each thread service N clients? If you're blocking, and you want to make sure each socket gets its data processed regardless of the state of the rest of the sockets, you have to have one thread per socket. That, or don't use blocking sockets.
Oct 31, 2013 at 13:13 vote accept Yannick Lange
Oct 31, 2013 at 15:11
Oct 31, 2013 at 13:12 comment added Yannick Lange @Philipp I didn't tell which programming language I use because, I thought it wasn't really relevant to the question (I use c++ by the way). I thank you for your recommendation to use asynchronous socket. Do you know a recommended book/webpage for learning these types of methods in game(engines)?
Oct 31, 2013 at 12:22 comment added Philipp @Grimshaw I think you misunderstood my answer. I think I have now clarified that a multi-threaded model would be required when using blocking sockets.
Oct 31, 2013 at 12:20 comment added Grimshaw why does he need a thread for every single socket? Especially with async sockets? Many heavyweight servers use a "thread pool" model to process socket data, where each thread services N clients and they are spawned or killed as needed. Just think this answer needs an improvement :D
Oct 31, 2013 at 12:19 history edited Philipp CC BY-SA 3.0
added 57 characters in body
Oct 31, 2013 at 11:58 history answered Philipp CC BY-SA 3.0