Server-Client Architecture
Client vs Server
If you are asking what is this Clients and Servers I don’t understand, that good we’ll begin from there.
A client is any device which is asking for a requests a service from another device or program.
A server is a device which takes, and collects requests from clients and serves them according to the request and permissions that are allowed for that individual client.
That’s it!!
The Request-Response cycle
Its not exactly similar but some-what give some, take some mode.
GENERALLY the client asks for a request of a service or a program to a server, then the server responds with a response to the client.
(Ofc there are checks and authentication balances that comes to paly)
This is a basic understanding, now you know what is going onnn.
Lets take a closer look:
Client’s Request : A User performs an action in their web-browser, such as a URL, the request can be of many types based on what the client is sending request for»
GET: Retrieve data from the server
POST: Send data to the server
PUT: Update existing data on the server
DELETE: Delete data from the server
The client sends request in form of a url (Uniform Resource Locator)
DNS Resolution:
If the URL contains domain name, the client needs to resolve this name to IP address using Domain Name System(DNS).
Establishing a TCP Connection:
HTTP uses TCP/IP suite for communication, That follows the Three way handshake The client initiates a connection with the server at the resolver IP address and the appropirate port usually port 80 for HTTP or 443 for HTTPS.
That requires a three-way handshake to establish a reliable connection.
In a three-way-handshake we get the request-response-acknowledge
Sending request: The client sends HTTP request message over the established TCP connection.
Server receivers and processes the request: The server receives the request.
The server parses the request message to understand the client’s request (method, URL , headers, body )
Server Responds: The server creates a HTTP response message. This contains the details about the response also the response is present in it.
Status code: The status code is determined on the basis of how the response is processed if it is ok it follows 200 series if there is an error we go 500 etc.
Header: Provides additional information about responses, what is the length of the resonse, content-type, set-cookie. etc.
Cookies: This contains the cookies if any.
Client receives response:
The client receives the response and the processes it, renders it, and handles it appropriately
Closing the Connectivity: The TCP connection is closed as soon as the above steps are completed that gives the internet a STATE-LESS standard of living where no request has any idea about the previous requests or responsses.