What is a Socket?

Socket acts as an endpoint to communicate two computers with one another in a computer network. When two applications running on two different machines want to send data, a socket is used to transfer by connecting ports on the machines through their IP addresses. It is executed by the transport layer such as a TCP/IP model or OSI model using protocols like TCP, and UDP.

The client sends a request to the server by establishing a connection through the server port and its IP address. Socket address is the combination of socket and IP address. For example, the IP address is 10.10.10.10 and the port number is 80, so the socket address is 10.10.10.10:80.

There are three types of sockets available:

a) Stream socket (Connection-oriented): Error-free, reliable, and bidirectional. It uses Transmission Control Protocol (TCP) to deliver sequential packets by establishing a connection. Applications used here are Telnet/SSH, HTTP, HTTPS, etc.

b) Datagram socket (Connectionless): This type of socket is unreliable and the best. It uses User Datagram Protocol (UDP) to deliver datagrams based on order and there is no connection establishment required. An example of this type is live-streaming audio or video files.

c) Raw socket: It provides access to Internet Control Message Protocol (ICMP) which injects packets with customized headers and data into the network directly.

Comments

Popular posts from this blog

How to Install Jenkins

HTTP Payloads

Variables in Postman