Summary

Blocking sockets work great on platforms that provide a multithreaded execution environment. Unfortunately, the Palm OS is not one of those platforms. To a large extent we can address this by providing relatively short timeouts to networking functions in a polling architecture. But there are limits to how short the timeouts can be. And until the timeout expires, the user is unable to use their device.

By switching to nonblocking sockets, we can make our application more responsive and our user happier. Network functions called against nonblocking sockets return immediately, whether the operation completes or not. This change is most obvious in handling connections, but it has implications to accepting connections and sending and receiving data as well.

Fortunately, we addressed many of the implications of moving from blocking sockets to nonblocking sockets in previous chapters. We had to rearrange our existing code a bit, but the basic architecture was unchanged.

The most obvious result of switching to nonblocking is that the application executes more smoothly. This provides the user with the experience of better performance, even if the performance is not actually that much better.

With this improvement, we are done with TCP sockets. FtpView is far from a complete FTP client. I will leave it as an exercise for you to add the remaining functionality; I have provided all the pieces you need. In the next chapter, we enter the exciting world of the User Datagram Protocol, ...

Get Palm OS Network Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.