Client-Server Communication
In this article, we will learn how communication takes place between the Client and the Server.
Request-Response Model:
The client & the server have a request-response model. The client sends the request & the server responds with the data.
If there is no request, there is no response.
HTTP Protocol:
The entire communication happens over the HTTP protocol. It is the protocol for data exchange over the World Wide Web. HTTP protocol is a request-response protocol that defines how information is transmitted across the web.
It’s a stateless protocol, every process over HTTP is executed independently & has no knowledge of previous processes.
REST API & API Endpoints:
Speaking from the context of modern web applications, every client has to hit a REST end-point to fetch the data from the backend.
The backend application code has a REST-API implemented which acts as an interface to the outside world requests. Every request be it from the client written by the business or the third-party developers which consume our data have to hit the REST-endpoints to fetch the data.
Real World Example Of Using A REST API:
For instance, let’s say we want to write an application which would keep track of the birthdays of all our Facebook friends & send us a reminder a couple of days before the event date.
To implement this, the first step would be to get the data on the birthdays of all our Facebook friends.
We would write a client which would hit the Facebook Social Graph API which is a REST-API to get the data & then run our business logic on the data.