Sockets and Transport Layer Notes
A Socket is one endpoint of a two-way communication link between two programs running on the network. It is formed by combining the IP address with the port number. If the IP address is 200.145.20.4 and the current application is running on port 4563. The the socket would be:
200.145.20.4 : 4563
Sockets sits between the application and transport layer, it is what is used to connect both layers together.
There are two types of sockets, there are two protocols that run in the transport layer and hence two types of scokets. TCP (transmission control protocol) socket and UDP (user datagram protocol) socket.
Here is a comparison between both and how they are used:
TCP Socket
Reliability: Highly reliable with error checking and correction. It ensure that data is sent and received in the correct order.
Connection: Connection-oriented. Connection is established before data can be sent.
Speed: Slower than UDP due to additional overheads.
Use Case: Accuracy and reliability is important
UDP Socket
Reliability: Less reliable, no guarantee of packet delivery, order or error checking.
Connection: Connectionless: data is sent without establishing a connection, leading to faster transmission.
Speed: Faster as there is no additional overheads.
Use Case: Speed and efficiency are more important than accuracy.