HTTP stands for Hypertext Transfer Protocol. HTTP works similarly to other application services such as SMTP and FTP. Like the performance of FTP, HTTP transfers documents using the TCP port service. But HTTP only uses one TCP connection at the data link and no single Control Connection is used.
HTTP is a protocol that fetches resources such as HTML documents. It is used for exchanging data over the web and is a client-server protocol (ie requests are made by the receiver, usually the web browser).
Client-side control operations are sent in a request to the web server. Web server sends the requested content at a response message. HTTP does not provide any security and uses SSL (Secure Socket Layer).
How does HTTP work?
HTTP provides users with a way to deliver hypertext messages between the server and the client for interaction. HTTP clients typically use Transmission Control Protocol (TCP) connections to communicate with the server.
HTTP uses various tasks which are performed using the following methods:
- GET = Requires specific sources.
- HEAD = A specific resource with no main content.
- POST = Add articles, messages, and information to another page in an existing web resource.
- PUT = Directly modify existing web source and create a new URL if needed.
- DELETE = Exclude a specific source.
- TRACE = Show the user any modifications or additions made to the Internet resource.
- OPTIONS = Show the user what HTTP methods are available for a particular URL.
- CONNECT = Link conversion required.
- PATCH = Modified part of Internet resources.
The HTTP server uses GET and HEAD methods.
What is TCP?
TCP is a connection-oriented protocol, indicating that a connection is established and maintained until application data at each end ends the exchange. TCP divides application data into packets. This package distributes to the transport layer. Layer 4 manages the flow control and provides error-free data transmission, handles retransmission of lost or truncated packets, and acknowledgment of all incoming packets. In the OSI model, TCP includes parts of Layer 4 (the transport layer) and Layer 5 includes the session layer.
How TCP works
TCP’s job is to ensure that all data sent in the flow moves from client to server in correct order and intact. TCP uses a technique known as Positive Acknowledgment on retransmission, requesting the receiver of the transmission to give a response on what data was received. The bytes sent can exactly match the received bytes. No data is changed or lost along the way.
A connection is established and a 3-party association is made. The source first sends a SYN request to the server to initiate the session setup. Then, the server sends a SYN-ACK packet to agree with the process. Finally, the source sends an ACK packet to the destination to validate the process, then data can be sent.
Compare TCP and HTTP
1. HTTP is used for accessing websites, while TCP is the protocol that establishes the session between client and server.
2. HTTP uses port 80 and TCP doesn’t use port.
3. HTTP does not need authentication, while TCP uses TCP-AO.
4. HTTP is a one-way communication system, while TCP has a combination of 3 elements (SYN, SYN-ACK, ACK).
5. In case you are using HTTP, HTTP will appear in the website URL and if you are using TCP, TCP will appear in the IP.
6. HTTP establishes the data link communication, while TCP establishes the session connection.
7. HTTP is useful for transferring smaller documents like web pages, on the other hand TCP is useful for establishing connections for data transfer.
8. HTTP is faster than TCP.
Source content: Difference between HTTP and TCP