Connectionless vs. connection-oriented
UDP vs. TCP
Reliability issue? TCP wins.
Support of broadcast or multicast? UDP wins.
Real time applications? UDP may win.
Client and server must use the same protocol
3
Iterative vs. concurrent
Iterative server handles one request at a time.
If another request arrives while the server is busy
handling an existing request, the new request has to
wait.
Iterative servers are easier to design, implement, and maintain.
Iterative server is not good for a service with a long “request
processing time”.
Concurrent server handles multiple requests
concurrently.
It can decrease the response time.
It can achieve high performance on a server with multiple
processors.
It can achieve high performance by overlapping processing
and I/O.
4
5
server
client being
served waiting clients
6
1.Create a datagram (UDP) socket and bind to the well-known
address for the service being offered.
2.Repeatedly receive the next request from a client, formulate
a response, and send a reply back to the client according to
the application protocol.
7
It is the most common form of connectionless server, used
especially for services that require a trivial amount of
processing for each request.
1.Create a stream (TCP) socket and bind to the well-known address for the
service being offered.
2.Place the socket in passive mode, making it ready for use by a server.
3.Accept the next connection request from the socket, and obtain a new
socket for the connection.
4.Repeatedly receive a request from the client, formulate a response, and
send a reply back to the client according to the application protocol.
5.When finished with a particular client, close the connection and return to
step 3 to accept a new connection.
8
A less common server type used for services that require a trivial amount of
processing for each request, but for which reliable transport is necessary.
Master 1. Create a socket and bind to the well-known address for
the service being offered. Leave the socket unconnected.
Master 2. Repeatedly call recvfrom to receive the next request
from a client, and create a new slave thread to handle the response.
Slave 1.Receive a specific request upon creation as well as access to the
socket.
Slave 2.Form a reply according to the application protocol and send it
back to the client using sendto.
Slave 3.Exit (i.e., a slave thread terminates after handling one request).
9
It is an uncommon type in which the server creates a new thread
to handle each request.
Master 1. Create a socket and bind to the well-known address for
the service being offered. Leave the socket unconnected.
Master 2. Place the socket in passive mode, making it ready for
use by a server.
Master 3. Repeatedly call accept to receive the next request from
a client, and create a new slave thread to handle the response.
Slave 1.Receive a connection request (i.e., socket for the connection)
upon creation.
Slave 2.Interact with the client using the connection: receive request(s)
and send back response(s).
Slave 3.Close the connection and exit. The slave thread exists after
handling all requests from one client.
10