Chapter 8 discusses how to connect to a remote host on the network. This chapter is about exchanging data across a socket connection, which is largely what the Net is all about. Everything else is just infrastructure and protocols that you can generally ignore when developing Network Applications.
The Network Library provides support for exchanging data with a remote host either as “streams” of incoming or outgoing data, or individual data packets. In this chapter, we explore streams of data. Streams are based on the TCP protocol, packets are supported by the UDP protocol. We cover TCP streams in this chapter. UDP and datagrams are discussed in Chapter 13.
We explore the File Transfer Protocol (FTP) as an example of sending and receiving data. FTP allows clients to store and retrieve files from a file server across a TCP/IP network. In this chapter, we discuss the logistics of logging in and out from an FTP server.
TCP and the Sockets API provide a simple yet powerful interface for exchanging data. TCP Socket connections present data as a stream, where bytes flow in at one end and flow out at the other in the same order, like box cars on a train going through a tunnel.
The TCP layer maintains a set of buffers for each socket. When an application sends data, the data is copied to the outbound buffers and control returns to the application.
The protocol stack is an operating system service that runs on its own thread. ...