
COMMUNICATING IN (NEAR) REAL TIME 149
Transmission Control Protocol: Sockets & Sessions
For example, think about the exchanges between a web
client and server that you saw in the last two chapters. The
pipe is opened when the server acknowledges the client’s
contact, and remains open until the server has finished
sending the data.
There’s a lot going on behind the scenes of a socket con-
nection. The exchange of data over a TCP connection can
range in size anywhere from a few bytes to a few terabytes
or more. All that data is sent in discrete packets, and the
packets are sent by the best route from one end to the
other.
NOTE: “Best” is a deliberately vague term: the optimal route is
calculated differently by different network hardware, and involves
a variety of metrics (such as the number of hops between two
points as well as the available bandwidth and reliability of a
given path).
The period between the opening of a socket and the suc-
cessful close of the socket is called a session. During the
session, the program that maintains the socket tracks the
status of the connection (open or closed) and the port
number; counts the number of packets sent and received;
notes the order of the packets and sees to it that packets
are presented in the right order, even if the later packets
arrive first; and accounts for any missing packets by
requesting that they be re-sent. All of that is taken ...