Client/server Programs in Java

One of the central ideas of network computing is client-server model. Many networking applications including the Internet’s primary protocols such as HTTP, SMTP, DNS, etc. use this model. It has some distinct advantages over its counterpart, the peer-to-peer model (P2P) where peers are equally privileged, equipotent participants [Figure 13.2:]. Note that sockets may also be used to develop applications for P2P network model.

Figure 13.2: Network architecture (i) Peer-to-peer (ii) Client-Server

In client-server programming paradigm, there are two primary components (programs): service providers, known as server programs (or simply servers) and service requesters, known as client programs (or simply clients). Since, client-server model uses two types of applications, it is sometimes referred to as two-tier model. Server programs (which are usually written to provide powerful services) are usually run on high-performance computers and share resources with its clients. Client programs, which usually run on different computers, make use of these resources to perform its designated task.

Each client sends one or more service requests to one or more servers. The servers, in turn, accept these requests, process them and provide the requested service (e.g. sending requested information). This simple but powerful idea can be used in a variety of network applications, though the fundamental concept remains the same.

A server may provide a variety of services such as web service, remote login service, mail service, database service, file service, name service, print service, and many more. One server may provide multiple services. Similarly, one client may get many services from the same or different servers. A program may act as a server or as a client or both (logically). Popular clients include web browsers, chat clients, email clients, etc.

The client process becomes sender of data (if any) at some point of communication and the server process becomes the receiver of that data. At some other instant of communication, the server process becomes the sender of data (if any) and the client process becomes the receiver of that data. Depending on the number of receivers, data communication may be categorized as uni-cast, multi­cast and broadcast [Figure 13.3:].

When data is sent by one process to another single process, it is known as uni-cast communication. In this case, there is exactly one sender and one receiver. On the other hand, when there exists multiple (but not all) receivers of the data, it is said to be multi-cast. If all are intended receivers, it is said to be broadcast. Note that broadcast is a special case of multicast, when all entities become receivers

Source: Uttam Kumar Roy (2015), Advanced Java programming, Oxford University Press.

Leave a Reply

Your email address will not be published. Required fields are marked *