Client/Server - Sockets Programming

Issues

Client Design

    lecture, HW3

Server Design

    lecture, HW2 & 3

Sys. Architecture

    HW3, Case Studies

Protocol Design

    HW3, Case Studies

Issues in Client Programming

Identifying the Server

Options:

Identifying a TCP/IP server.

Host Names

The Domain Name System

DNS Hierarchy

Looking up a Domain Name

Services and Ports

Specifying a Local Address

Local IP address

UDP Client Design

  1. Establish server address (IP and port).
  2. Allocate a socket.
  3. Specify that any valid local port and IP address can be used.
  4. Communicate with server (send, recv)
  5. Close the socket.

Connected mode UDP

TCP Client Design

  1. Establish server address (IP and port).
  2. Allocate a socket.
  3. Specify that any valid local port and IP address can be used.
  4. Call connect() l Communicate with server (read,write).
  5. Close the connection.

connect()

Closing a TCP socket

Partial Close

TCP sockets programming

TCP Reads

Reading n bytes

int readn( int sd, char *buf, int n) { 

Reading a line

int readline( int sd, char *buf, int max) {

int i=0;

if (read(sd,buf,1)!=1)

buf[i]=0;

return(i);

Server Design

Iterative

Conectionless

Iterative

Connection-Oriented

Concurrent

Connectionless

Concurrent

Connection-Oriented

Concurrent vs. Iterative

Concurrent vs. Iterative

Connectionless vs. Connection-Oriented

Statelessness

The Dangers of Statefullness