It's not like you don't have cores/threads for blocking when you just have one server, how many servers are they going to connect to?
Or is this for the Unity server part?
It's not like you don't have cores/threads for blocking when you just have one server, how many servers are they going to connect to?
Or is this for the Unity server part?
It fits in nicely with how everything else works in your game loop, and means you don't need to deal with marshalling data to/from a dedicated thread.
Select returns the list of non-blocking sockets that have data read/write pending.
BTW, the sockets themselves don't even have to be non-blocking.
Also, I'd like to stress that the concepts or blocking/non-blocking I/O and synchronous/asynchronous I/O are really orthogonal. You can do synchronous networking with non-blocking sockets and vice versa.
There is no practical difference between blocking on select() for multiple sockets or blocking on recv() for a single socket - in both cases the thread can't do anything else.
Some platforms don't have these luxuries.
The age is relative, sockets are from the 70s, non-blocking is 2000+ and in most languages it's only stable since 2010+.
No, the client would have one thread for everything, not one thread for networking. You shouldn't do blocking IO if you only have one thread that also needs to do other things.