O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

More Advanced Issues

Multiplexing connections

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required