Java Reference
In-Depth Information
(IANA) oversees this assignment. For example, port number 21 has been assigned to the File
Transfer Protocol (FTP) . When you run an FTP client application, it tries to contact the FTP
server on that port by default. A list of all the assigned port numbers is maintained by the
numbering authority of the Internet (see http://www.iana.org/assignments/port-numbers ).
1.5
What Is a Socket?
A socket is an abstraction through which an application may send and receive data, in much
the same way as an open file handle allows an application to read and write data to stable
storage. A socket allows an application to plug in to the network and communicate with other
applications that are plugged in to the same network. Information written to the socket by
an application on one machine can be read by an application on a different machine and vice
versa.
Different types of sockets correspond to different underlying protocol suites and different
stacks of protocols within a suite. This topic deals only with the TCP/IP protocol suite. The
main types of sockets in TCP/IP today are stream sockets and datagram sockets . Stream sockets
use TCP as the end-to-end protocol (with IP underneath) and thus provide a reliable byte-
stream service. A TCP/IP stream socket represents one end of a TCP connection. Datagram
sockets use UDP (again, with IP underneath) and thus provide a best-effort datagram service that
applications can use to send individual messages up to about 65,500 bytes in length. Stream
and datagram sockets are also supported by other protocol suites, but this topic deals only
with TCP stream sockets and UDP datagram sockets. A TCP/IP socket is uniquely identified by
an Internet address, an end-to-end protocol (TCP or UDP), and a port number. As you proceed,
you will encounter several ways for a socket to become bound to an address.
Figure 1.2 depicts the logical relationships among applications, socket abstractions,
protocols, and port numbers within a single host. Note that a single socket abstraction can
be referenced by multiple application programs. Each program that has a reference to a
particular socket can communicate through that socket. Earlier we said that a port identifies
an application on a host. Actually, a port identifies a socket on a host. From Figure 1.2, we see
that multiple programs on a host can access the same socket. In practice, separate programs
that access the same socket would usually belong to the same application (e.g., multiple copies
of a Web server program), although in principle they could belong to different applications.
1.6
Exercises
1. Can you think of a real-life example of communication that does not fit the client-server
model?
2. To how many different kinds of networks is your home connected? How many support
two-way transport?
Search WWH ::




Custom Search