Non-blocking reads

If a process takes a long time to return output, you don’t want your application to stop while waiting for output from the program. To avoid this case, you create a file handle that does non-blocking reading. In particular, you set up the file handle so that it posts a notification when there is data to be processed.

In this section, you are going to create a task which runs traceroute. traceroute sends out packets to discover the routers between your machine and another host. The responses from the routers sometimes take a while to get back. You will read the data in the background and append it to the text view.

The notification created will be an NSFileHandleReadCompletionNotification. To start the file handle waiting for ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.