O'Reilly logo

Palm OS Network Programming by Greg Winton

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

Nonblocking Sockets

However we slice it, our application is eventually going to timeout on network operations. And while it waits for this timeout, the rest of the user interface will come to a complete halt. The user can select controls, push hardware buttons, turn the device on and off, i.e., do just about anything. The device ignores them; to the casual observer, the device seems dead for a few seconds. It’s not a satisfying user experience to have the device go dead for a couple of seconds.

The solution is nonblocking sockets. In Chapter 6, we discuss the architectural division between the Palm OS Net Library and the TCP/IP protocol stack. When we look at any network operation, there are two stages to it. There is the stage during which the TCP stack handles the connection semantics, storing inbound data into buffers, sending outbound data from buffers, and making and accepting connection requests. There is also the Net Library function stage, where the results of these network operations are returned to the application.

Since then, we have paid little attention to this division. With blocking sockets, these phases are tightly coupled. Net library function calls initiated network operations and waited for them to complete before returning.

Nonblocking sockets fit well with the division between Net Library functions and the protocol stack’s network operations. Net Library functions simply check the state of a network operation. If an operation does not return immediately, the ...

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