Client Server Model

Client Server Model

Java provides API(Application Programming Interface) to develop distributed applications that follow the Client-Server model. Before jumping to the client-server model let us first understand the distributed application.

Distributed Applications

In distributed applications, the same application can run across different machine at the same time using the internet, Where one machine can act as Server where the application is deployed and the other machine act as a Client.

Client Server

The client-server model is a distributed application structure that partitions tasks or workloads between the providers of a resource or service(web servers) and service requesters(clients).

Here both the client and server are programs. From now on the client means we will be talking about the 'program' which is making requests, not the end user.

Client-Server Architecture

The above diagram illustrates the client-server architecture, here clients mean any web browser or application program that sends requests to the web server. And web server is something where we host a web application a database application or could be an email server. In response to the moment we send an HTTP request to the web server, the web server gives the response. HTTP(Hypertext Transfer Protocol) is a TCP/IP-based communication protocol, which is used to deliver data over the web(for more understanding of protocol, you can go through the layers of TCP/IP protocol). It provides a standardized way for the client to communicate with the server.

Here we can see the web client make requests through HTTP to the web server, which is hosted on PORT:8080 on localhost, followed by the application name. This application name is a custom application name that you can host on the web server.

The web server accepts the requests from the client and gives back a response which can be either a static or dynamic HTML page.

URL

Uniform Resource Locator(URL) uniquely identifies a resource on the internet and follows HTTP protocol.

HTTP

HTTP (Hypertext Transfer Protocol) is a TCP/IP-based communication protocol, which is used to deliver data over the web. This protocol is used to change or transfer the hypertext. Hypertext is a structured text that uses logical links between containing text.

It is a stateless protocol - it does not require the HTTP server to retain information about each user.

Server Response

The server generates a response to the Client's request. It sends three things:

  1. A status, that tells whether the client's response has successfully reached the server or not. Example: 404: error for page not found.

  2. Information about the type of content that the server is going to send. The server sends HTML pages as the response.

  3. The actual content, for example: when the client types google.com in any browser, the server navigates the client to the google home page.

Server Response Types

As we have read above that in response HTTP sends an HTML file, which can be static or dynamic.

Static Page: There is no change in the content, Client requests a web page and the server gets the page. Example: When we search google.com, the Google server sends the same home page to every client's request.

Dynamic Page: The page content changes frequently. The server may not be able to process the request. Example: When we log in to Instagram or Facebook for every client the home page (feed) changes as per their followed content which is not the same for everyone, and it changes with every request.

Thank you for reading. Hope you understood the concepts.

Did you find this article valuable?

Support Abhishek Madankar by becoming a sponsor. Any amount is appreciated!