August 2011
Intermediate to advanced
552 pages
23h 48m
English
A one-connection-at-a-time server like simpleserver is OK for some applications, but to truly leverage the power of networking, it is better to have a single server support many connections simultaneously. To do this, you need a way to multiplex multiple input and output streams and only block when there is no work to be done.
The select() call is the Berkeley sockets way of doing this multiplexing. You will see in Chapter 16: kqueue and FSEvents an alternate way of multiplexing connections, which is superior to select() in many ways, but it is not available on many platforms. Grand Central Dispatch also gives you a way to multiplex sockets.
For select(), you give it a set of file descriptors. If ...
Read now
Unlock full access