The Transmission Control Protocolis a protocol that is used for the highly reliable host-to-host data communications between computers in a packet-switched computer communication network, such as the Internet. TCP assumes there is an underlying protocol to route the individual packets of data through the network. Most of the time IP is used to to do that. Therefore the combination TCP/IP is commonly used to refer to communications on the Internet.
IP is responsible for the transportation of individual packets of data from the source to the destination. However IP is only a best-effort delivery. Correct transportation is not guaranteed. TCP is responsible for verifying the correct delivery of data from source to destination. TCP adds support to detect errors or lost data and to trigger retransmission until the data is correctly and completely received.
Due to TCP, the application thinks it has a reliable connection. TCP first sets up a connection between the source and the destination. It opens a communications port on the computer. The combination of IP-address and communications port is called a socket.
If the coonnection is set up, TCP divides the data into smaller segments. These segments are given a sequence number and a checksum. The segments are given to the IP protocol for the transport through the network. At the receiver the segments are checked for errors. Faulty segments are thrown away and a retransmission is asked for. For each segment that is correctly received, an acknowlegment is send back. The segments are put in the right order and delivered to the application of the destination computer. If all data has been send, the connection is broken down.
A general description of TCP is given in RFC 793.