HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP) is a protocol for browsers to request information from a server. It's like the language that a client and the server use to communicate with each other. You don't notice it as a normal user, but there is some back and forth communication happening between a browser and server. A particular client might only support a certain data or image format. Therefore, a client can request to receive data in a supported format. This is similar to a person with a food allergy ordering a dish with certain ingredients. Another example is when a client requests that a secure connection should be used to communicate via HTTPS which by the way is the encrypted and therefore secure version of HTTP. The type of back-and-forth communication mentioned in the two examples above is known as a negotiation.
Even before such negotiations there is communication in the form of a TCP handshake happening between a client and server to establish a connection between the two. Continue reading to learn more.
TCP Handshake
TCP Handshake: Once the client knows the server's IP address, it initiates a TCP (Transmission Control Protocol) handshake. TCP is a reliable and connection-oriented protocol that ensures data integrity during transmission.
The client sends a TCP SYN (synchronize) packet to the server, indicating its intention to establish a connection.
- The server receives the SYN packet and responds with a TCP SYN-ACK (synchronize-acknowledge) packet, acknowledging the client's request and indicating its readiness to establish a connection.
- The client receives the SYN-ACK packet and responds with a TCP ACK (acknowledge) packet, confirming the establishment of the connection.
At this point, the TCP handshake is complete, and a reliable connection has been established between the client and the server.
HTTP Request: With the TCP connection established, the client can now send an HTTP request to the server. The request typically includes information such as the desired resource (e.g., a webpage URL), HTTP method (e.g., GET, POST), headers, and any additional data.
HTTP Response: The server receives the client's HTTP request, processes it, and generates an appropriate HTTP response. The response includes the requested resource, along with headers and a status code indicating the outcome of the request (e.g., 200 OK for a successful response).
Data Exchange: Once the server generates the HTTP response, it sends it back to the client over the established TCP connection. The client receives the response and can begin processing the received data, such as rendering a webpage or handling the server's instructions.
Throughout this process, the client and server exchange packets using TCP/IP protocols. The TCP handshake establishes a reliable connection, and the subsequent HTTP request and response enable the client and server to communicate and exchange data effectively.
Typical TCP Joke
"Hi, I'd like to hear a TCP joke."
"Hello, would you like to hear a TCP joke?"
"Yes, I'd like to hear a TCP joke."
"OK, I'll tell you a TCP joke."
"Ok, I will hear a TCP joke."
"Are you ready to hear a TCP joke?"
"Yes, I am ready to hear a TCP joke."
"Ok, I am about to send the TCP joke. It will last 10 seconds, it has two characters, it does not have a setting, it ends with a punchline."
"Ok, I am ready to get your TCP joke that will last 10 seconds, has two characters, does not have an explicit setting, and ends with a punchline."
"I'm sorry, your connection has timed out.... Hello, would you like to hear a TCP joke?"
from: https://www.reddit.com/r/ProgrammerHumor