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
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.