Typical examples of interprocess communications mechanisms include files (limited to shared filesystems), pipes (only useful where processes share a common parent process), shared memory, named pipes, message passing, and sockets.
The socket abstraction is the usual method of performing network-based interprocess communications in UNIX and many other systems. Sockets provide the interface to the transport layer, TCP, see later.
TCP is always implemented in conjunction with IP, the Internet Protocol[1] which provides the necessary network service. It is important to note that IP provides an "unreliable" packet delivery service, and may fail to deliver some packets. Furthermore, it may accidentally duplicate packets, and may even deliver them out of order.
The function of the TCP protocol, then, is to provide a:
The last byte in each segment is identified with a byte count field in the segment header.
[2] The TCP timeout algorithm uses observed round trip times, and measures of their variability, to calculate a continuously updated best estimate of when to resend.
Note:![]()
If a segment is lost in the network, the sender times out and re-transmits, thus:![]()
To do this, it defines an abstract address called a port number. Two processes can communicate by agreeing on the port numbers they will use for communications. Port numbers are the addresses of the TCP protocol - each segment contains port numbers for each of the sending and receiving processes[3].
In order to set up a TCP connection, a process notifies the TCP software that it is waiting for connections "at" a certain port number. By definition, such a process is called a server. A client process which needs to connect to the server asks its local TCP software to allocate an unused port number and establish the connection. Once the connection is established, the two processes can communicate.
In order to manage TCP connections, a group of port numbers (0 to 1023) have been defined to be used by processes providing well known services. Most UNIX systems provide server processes corresponding to all the well-known services.
[3]* In the second lecture they were referred to as Service Access Points (SAPs)
Note that the port number is used to name processes. Because the client establishes communication, it does not need a well-known port number, and so an unused one (> 1023) is randomly allocated by the TCP software, eg:![]()
The 3-way handshake is necessary because TCP is layered on the unreliable datagram service provided by IP, so that these control segments can be lost, duplicated or delivered out of order.![]()
This could lead to trouble if original or retransmitted segments arrive while the connection is being established - the handshake used overcomes this problem.
A TCP connection is closed using another (modified) 3-way handshake sequence involving the use of FIN control segments. An interesting consequence of the full-duplex nature of TCP, and the concept of graceful close is that a TCP connection can be half-open if one side closes the connection and the other does not.