Request Response Explained

Table of contents

No heading

No headings in the article.

In this blog we are going to understand:

  • What is a client?

  • What is a server?

  • Client VS Server:

Introduction:

Before jumping into the explanation of the concepts below in a beginner-friendly way, let's start by highlighting some sort of questions that come to mind whenever you use your browser. From where all this came and where it was and how that happened. Those questions frequently popped into my mind and I never got an answer for them honestly, after years of studying computer science I can how this orchestra works to some extent.

What is a client?

Most simply a client is any device that needs something from another source so it requests to get it. The most common example here is when you open a new tab in your browser on any device and you type in the URL of the website let's say google.com and then you hit enter by hitting the enter button you are making what we call a request to a certain server.

What is a server?

The server is another device that has the information you need to get. In this case the google.com home page. It's any party that owns a service which certain people request

Client VS Server:

Let's make an analogy to simplify the concept more: let's say you want to eat a pizza so you go to a restaurant we can think of the restaurant here as your browser to make your food order (your request ) you need to go to a restaurant you choose a table and sit down, the waiter comes to take your order, here you will specify your details about your order, for instance, the size of the pizza the ingredients those specifications are universal and should be done whenever you want to order a pizza, which makes them like a protocol for pizza ordering, in the same way, the HTTP is the protocol that defines how the request you're going to send to the server is formatted. The format of an HTTP request includes the HTTP method (such as GET, POST, PUT, DELETE), the URL (Uniform Resource Locator) of the resource being requested, and headers that convey additional information, for the sake of simplicity we will take about the GET request which describes exactly what you want to do by ordering a pizza you want to get a pizza from the restaurant's kitchen which will be our server here. So let's break it down :

Client: You

Request: Ordering a pizza

Method: GET (You want to get food)

Server: Restaurant's kitchen

HTTP Protocol: Pizza ordering protocol

Now you've made your request the waiter writes down your order and takes it to the kitchen from where your food is going to be brought back to you by the waiter again. The food is the response here.

Response: Food

Waiter: Network

So whenever a device requests something from another party it is called a client and the one who is supposed to respond is called the server for this case.

Note: A client can also be a server and a server might be a client as well how is that? When the server who is the one giving a certain service starts to ask a third party for another service it becomes a client. Let's understand in the context of pizza when you made your order the restaurant might not have had time to prepare the pizza dough which is the dough used as the base for making pizzas, to its request pizza dough from someone who is specialized in making those in this scenario, the restaurant's kitchen who is considered as a server for you is a client in the communication between them and the dough pizza maker as a result this last is another server in this case.