HTTP (Hypertext Transfer Protocol) and TCP (Transmission Control Protocol) are protocols used in computer networking, each with a different role that it plays.
A protocol is simply a set of rules that allow devices to communicate with each other.
TCP is a lower-level protocol than HTTP, and it is responsible for the reliable transmission of data across a network. When two devices want to communicate with each other, they establish a TCP connection.
Once the connection is established, data can be transmitted between the devices in a reliable and efficient manner.
TCP ensures that the data is transmitted in the right order, without errors, and without any data being lost along the way. It does this by using a system of acknowledgments and retransmissions.
When a device sends data, it waits for an acknowledgment from the receiving device to ensure that the data was received correctly. If an acknowledgment is not received within a certain amount of time, the data is retransmitted.
HTTP is a higher-level protocol that is built on top of TCP. HTTP is specifically designed for transmitting data over the World Wide Web (or Internet).
When you type a URL into your web browser and press Enter, your browser sends a request called an HTTP request to the web server that hosts the website you want to visit.
The server then sends back an HTTP response, which contains the data for the web page you requested for.
HTTP defines how the data should be formatted and transmitted between web servers and clients (such as your web browser). It specifies how web pages and other web resources, such as images and videos, should be requested and retrieved.
It is also responsible for tasks such as handling cookies (which are used to store information about your browsing session) and managing authentication (which is used to verify your identity when accessing certain websites).
Let’s say you’re trying to stream a video from a website. When you click on the video, your web browser sends an HTTP request to the web server that hosts the video. The server then sends back an HTTP response that contains the video data.
However, the video file is typically too large to be transmitted all at once. Instead, the video is broken up into smaller “packets” of data and transmitted over the network one at a time.
This is where TCP comes in. TCP ensures that each packet of data is transmitted correctly and reliably. When a packet is sent, the receiving device sends back an acknowledgment to let the sending device know that the packet was received correctly.
If the acknowledgment is not received within a certain amount of time, the packet is retransmitted.
Because TCP ensures that each packet of data is transmitted correctly and reliably, you’re able to stream the video smoothly and without any interruptions.
If TCP were not used, the video would likely be full of glitches and pauses, as packets of data may be lost or corrupted during transmission.
So, in this example, TCP is the underlying protocol that enables the smooth and reliable streaming of the video, while HTTP is the higher-level protocol that is used to request and retrieve the video from the web server.
With all that has been discussed so far, it can be summarized that the differences between TCP and HTTP are: