The transport layer is a part of the layered network model in computer networking. The main network protocols used are UDP and TCP. Applications will use transport layer sockets to communicate between each other.
Functionality
Transport layer libraries break application layer messages into segments, which are packaged and passed to the network layer. The receiver will reassemble the segments into messages, and pass them to the application layer.
One key mechanism is multiplexing and demultiplexing. Multiplexing is done at the sender to add the transport header (like source/destination port). De-multiplexing is done at the receiver, to use the header info to deliver the received segments to the correct socket.