Client/Server Computing Foundations: Sockets
Tom Kelliher, CS 318
Mar. 13, 2000
Read 25.1--25.7 (C version of the Perl client/server application.)
Read the Unix man pages for socket, connect, bind, and accept.
Internet bandwidth consumption explosion.
- Client/Server computing.
- Identifying the socket.
- Example client/server application.
Examining the client/server application: socket programming in Perl.
The protocol software cannot initiate contact with, or accept contact from,
a remote computer. Instead, two application programs must participate in
any communication: one application initiates communication and the other
The two applications each have unique roles:
This is the client/server paradigm.
- One actively initiates communication (the client).
- One passively waits for communication (the server)
This paradigm works for many internet application-level protocols:
Does data travel mostly from client or from server for each of these?
- POP, IMAP.
Information can flow in either direction, following the dictates of the
protocol. (Although you might think the client should say ``hello'' or
something of that nature. Compare telephone service model)
- Started by a user, runs for one session.
- Is not very specialized, performs local computations, becoming a
client when necessary.
- Runs on a local computer.
- Actively initiates communication with a specific server.
- Communicates with one server at a time.
- Communicates using whatever port, or set of ports, the protocol
software assigns it.
- Started by the system at boot time, runs for many sessions.
- Is a specialized, privileged program. Provides one service to many
clients at a time.
- Runs on a dedicated, remote, shared machine.
- Passively awaits communication from any client.
- Communicates using a specific, privileged port. So-called
- A server may itself become a client (to use DNS, for example).
Other server characteristics:
- Multiple servers on one computer.
- Multiple copies of a server for a single service. Iterative
servers. Forking (dynamic) concurrent servers.
- The Internet super server: inetd. Why do we have it?
What is a socket?
The interface between an application program and the communication
protocols at the transport or internet layers is the socket interface. A
socket is an application's communication connection.
- File access: A handle is bound to a name in the filesystem's name
space. At the time a connection is bound, the type of access (ASCII or
binary), mode (read, write, etc.), and the name of the file are specified.
- Communication access: A handle is bound to a communication channel in
the Internet name space. At the time a connection is made, the protocol
family (IP), the type of communication (stream or datagram), the transport
protocol, and the server IP and port (or listening port for server) are
Note the similarities: once set up, a socket handle is written/read in a
manner similar to a file handle. The difference: because of packet size
limitation, fragmentation, etc., multiple reads may have to be performed
for each write.
Problem: Three people, all on computer A are telnetted to computer B:
How do the two computers know which packets to deliver to which
A socket is completely specified by a four-tuple: (client port, client IP,
server port, server IP). This four-tuple accompanies each packet.
- Examples interacting with each other.
- Server interacting with telnet.
- Client interacting with daytime.
Thomas P. Kelliher
Mon Mar 13 10:01:02 EST 2000