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

15CFRunLoop

Unix networking uses file descriptors for reading and writing. Using file descriptors in server programs is pretty easy with the select() and kevent() functions. Using sockets in end-user GUI apps presents a problem, though. You cannot call select() on the main thread to wait for network activity. This will cause the UI to hang until there is something to be done on the network. Blocking the UI thread would cause your program to become unresponsive, and your process would be killed on iOS devices.

There are some options available to you. You can put your blocking function into a new thread. That thread can then block to its heart’s content until there is activity on the network, and then it can inform the UI thread that there is ...

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