Client/Server Computing Foundations: Sockets

Tom Kelliher, CS 318

Mar. 13, 2000

Administrivia

Announcements

Assignment

Read 25.1--25.7 (C version of the Perl client/server application.)

Re-read 24.8

Read the Unix man pages for socket, connect, bind, and accept.

From Last Time

Internet bandwidth consumption explosion.

Outline

  1. Client/Server computing.

  2. Identifying the socket.

  3. Example client/server application.

Coming Up

Examining the client/server application: socket programming in Perl.

Client/Server Computing

Fundamental rule:

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 accepts it.

The two applications each have unique roles:

  1. One actively initiates communication (the client).

  2. One passively waits for communication (the server)

This is the client/server paradigm.

This paradigm works for many internet application-level protocols:

  1. HTTP.

  2. SQL.

  3. Telnet.

  4. DNS.

  5. SMTP.

  6. POP, IMAP.

Does data travel mostly from client or from server for each of these?

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)

Schematically:

Client Application Characteristics

  1. Started by a user, runs for one session.

  2. Is not very specialized, performs local computations, becoming a client when necessary.

  3. Runs on a local computer.

  4. Actively initiates communication with a specific server.

  5. Communicates with one server at a time.

  6. Communicates using whatever port, or set of ports, the protocol software assigns it.

Server Application Characteristics

  1. Started by the system at boot time, runs for many sessions.

  2. Is a specialized, privileged program. Provides one service to many clients at a time.

  3. Runs on a dedicated, remote, shared machine.

  4. Passively awaits communication from any client.

  5. Communicates using a specific, privileged port. So-called well-known addresses.

  6. A server may itself become a client (to use DNS, for example).

Other server characteristics:

  1. Multiple servers on one computer.

  2. Multiple copies of a server for a single service. Iterative servers. Forking (dynamic) concurrent servers.

  3. The Internet super server: inetd. Why do we have it?

Identifying the Socket

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.

Comparison:

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 applications?

A socket is completely specified by a four-tuple: (client port, client IP, server port, server IP). This four-tuple accompanies each packet.

Example Client/Server Application

Example runs:

  1. Examples interacting with each other.

  2. Server interacting with telnet.

  3. Client interacting with daytime.



Thomas P. Kelliher
Mon Mar 13 10:01:02 EST 2000
Tom Kelliher