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

Chapter 12. Optimizing Stream Sockets

We are just about done with stream sockets. We can make and accept connections and send and receive data. We know just about everything we need to know to write efficient, enjoyable TCP/IP network applications. There are just a few last details to cover; a few refinements to your understanding of stream sockets.

In this chapter, I discuss socket operating modes. The Palm OS platform supports two socket operating modes: blocking and nonblocking. Our sockets have all operated in blocking mode. In this chapter, I discuss nonblocking mode. We explore the costs and benefits of switching from blocking to nonblocking sockets. We use nonblocking sockets to improve the FtpView user experience.

Socket Operating Modes

A blocking socket waits, or blocks, for network operations to complete. Nonblocking sockets do not wait. If an operation blocks, nonblocking sockets immediately return an error indicating this.

For example, let’s look at the receive operation. If we attempt to receive data from a blocking socket and there is no data to receive, the socket waits until the data arrives. A nonblocking socket, on the other hand, returns immediately from the receive operation with an error indicating that the operation would block.

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