TCP, or Transfer Control Protocol, is a fundamental component of the Internet and various other applications such as Email. Originally defined in 1981 through RFC 793, TCP has a longstanding history as one of the pillars of the Internet.
TCP operates on top of the Internet Protocol (IP) and serves as the foundation for application-level protocols like HTTP, FTP, IMAP, and many others. Unlike IP and UDP, TCP is a connection-oriented protocol. Prior to data transmission, a connection must be established. Data is then transmitted as packets, and once the communication is complete, the connection is closed.
When using TCP, a complex workflow known as a handshake is required for the transmission of data. While the details of this handshake are not discussed here, it plays a crucial role in establishing the end-to-end connection. One of the notable features of TCP is its reliability. Through the use of the handshake, TCP ensures that packets sent by the sender are correctly received by the receiver. In the event of packet loss, TCP can handle retransmission of the lost packet.
Unlike IP, which establishes connections between computers, TCP establishes connections between processes. These connections are identified using the concept of ports, which are associated with an IP address. For example, localhost:8080
or google.com:1234
uniquely identify a process on a computer. Each application protocol has a default port, such as 80 for HTTP, 443 for HTTPS, and 21 for FTP. This is why specifying the port is not usually required in a browser. However, programs have the flexibility to use ports other than the default, resulting in port numbers like 1313 or 8080 when starting a new application.
Port numbers range from 1 to 65535, encompassing a total of 2^16 possible values. It is important to note that programs are not obligated to use the default ports, allowing for customization and flexibility, especially on local computers.