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 11. Accepting Connections

In Chapter 8, we learn how to act as a client in a TCP connection. A TCP client initiates the connection with remote hosts. In this chapter, we learn how to serve these connections, accepting requests from remote hosts and we update FtpView to serve the FTP data connection.

The FTP data connection is used to exchange files and directory listings. These exchanges involve large amounts of data. In this chapter, we examine ways to handle this data efficiently.

Serving TCP Connections

Before we dive into the details of acting as a connection server for TCP sockets, let’s revisit the three-way handshake. The sequence of events in this handshake is illustrated in Figure 11-1.

TCP three-way handshake event sequence

Figure 11-1. TCP three-way handshake event sequence

First, the connection server opens a socket and binds it to a specific address and port number. Then the server puts the socket into passive listening mode. This tells the protocol stack to accept connection requests addressed to this socket. The protocol stack sets up two queues for incoming requests, one for incomplete connection requests and one for completed ones.

A connection request arrives as an incoming SYN segment. The TCP server responds with an ACK segment, and sends a SYN segment of its own. The connection request is moved to the uncompleted connection queue. When the TCP server receives an acknowledgment from the client, ...

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