next up previous contents
Next: TCP/IP and Security Up: An Overview of TCP/IP Previous: Transport Layer Protocols

   
Clients and Servers

At this point we have covered the underlying network transport mechanism, and can consider how distributed applications are built on top of this. Almost all network-based applications are based on a client-server model of interaction. A server  is a program1.2 that offers a service to other programs on the same or other hosts on the network. A client  is a program that requests service from a server. Servers usually run continuously and can typically service multiple requests from multiple clients, often concurrently. Clients, on the other hand, usually have a limited lifetime.

In the TCP/IP world, servers usually listen for requests on well-known ports  that have been reserved for their service (for example, mail servers typically listen on TCP port 25). Clients, on the other hand, use arbitrary, unused, non-reserved ports for their connection endpoints. By convention, port numbers less than 1024 are considered privileged and for use by servers, while port numbers greater than 1023 are considered non-privileged and for use by clients (there are a few exceptions to this). On UNIX systems, the file /etc/services contains the list of well-known UDP and TCP ports. Figure 1.3 lists some of the most common services and their associated ports.


  
Figure 1.3: Common TCP and UDP Services and Their Ports
\begin{figure}\centering
\begin{tabular}{\vert l\vert l\vert l\vert l\vert}
\hli...
...& UDP & 1525 & FTP index searching service \\
\hline
\end{tabular}
\end{figure}


  
Figure 1.4: Generic Network Server Algorithm
\begin{figure}\begin{tex2html_preform}\begin{verbatim}start listening for reques...
...ndle that client's request
end\end{verbatim}\end{tex2html_preform}
\end{figure}

Servers usually operate according to the general algorithm shown in Figure 1.4. By running a slave process to handle each client request, the server can deal with multiple concurrent requests. The algorithm is sufficiently general that it has led to the creation of the UNIX `Internet super server' program inetd . This program listens on a whole range of ports for different services, and when a request is received, spawns an appropriate slave process to handle the request (a few trivial services are handled internally by inetd itself). This simplifies the process of writing server programs considerably. inetd determines what ports to listen on and what slave processes to run by reading the configuration file /etc/inetd.conf.  


next up previous contents
Next: TCP/IP and Security Up: An Overview of TCP/IP Previous: Transport Layer Protocols
Copyright © 2004, CEQURUX Technologies