Socket and Port


Socket vs Port

In the context of computer networking, a socket is an end point of a bidirectional communication that occurs in a network that is based on the internet protocol. Sockets will distribute the data packets that are coming through the communication channel to the correct application. This is done using the information such as IP address and port number. In general a (software) port is a logical data connection that can be used to exchange data. On the internet TCP and UDP ports are used to exchange data between computers and these are the most widely used ports.



What is a Socket?

A socket is an end point of a bidirectional communication that occurs in a computer network that is based on the internet protocol. Sockets will distribute the data packets that are coming through the communication channel to the correct application. Operating system maps each socket to a process or a thread that communicates. There are two types of sockets called active sockets and passive sockets. An active socket is a socket that is connected to another active socket through a data connection that is open. Active sockets at both ends of the communication channel will be destroyed when the connection is closed. A passive socket is not participating in a connection, but a socket that is waiting for an incoming connection. When a passive socket is connected it will generate a new active socket. An internet socket is identified by the address of the local socket (local IP address and port number), address of the remote socket and the transport protocol (e.g. TCP, UDP).

What is a Port?

A port is a logical data connection that can be used to exchange data without the use of a temporary file or storage. On the internet TCP and UDP ports are used to exchange data between computers and these are the most widely used ports. Port is identified using a number associated with the port called the port number, the IP address associated with the port and the transportation protocol. Set of port numbers are generally reserved in a host computer for specific types of services. Port scanning is the process of attempting to connect to a set of ports that are in a sequence. In general, port scanning is considered as a malicious attempt. The system administrators conduct it to check for vulnerabilities in a system.

What is the difference between Socket and Port?

A socket is an end point of a bidirectional communication that occurs in a computer network that is based on the Internet protocol, whereas a port is a logical data connection that can be used to exchange data without the use of a temporary file or storage. A socket is associated with a port and there can be multiple sockets associated with a port. There can be a single passive socket associated with a port that is waiting for incoming connections. Furthermore, there can be multiple active sockets that correspond to connections that are open in that port.

No comments: