Transmission Control Protocol (TCP)
TCP is a more reliable, connection-based transport protocol compared to UDP. Its header is larger than UDP and all segments have sequence number. This allows TCP to reconstruct the correct order of packages. It can also ask for retransmission of a segment in case it is missing.

Establishing a TCP connection
Before any data is transmitted, the two hosts perform a so-called three-way handshake to initiate a connection.
The client sends that it wants to establish a connection (SYN) and that it will use the attached sequence number
The server will respond with SYN and ACK bits set, returning its own sequence number
Finally the client acknowledges with ACK with its next sequence number
Once a connection is established, each TCP segment is sent with the next sequence number.
Note
The connection is closed in a similar way.
Error Correction
Given that each TCP segment has a sequence number and checksum, errors can be easily detected and corrected:
Flow Control
TCP allows to detect if one side is sending data at a rate higher than what the receiver can handle. Or if there is congestion on the network and packages are dropped. TCP can slow down or increase the transmission rate to adjust to connectivity and traffic congestion. This is called flow control.
