It is referred to as an end point of a bidirectional communication which happens in a computer network that is completely based on IP (internet protocol). It distributes the data packets which come to the correct application from the communication channel. Operating system of the computer maps every socket to a thread or a process which eventually communicates.
There are mainly two types of sockets namely active sockets and passive sockets. In active socket, communication channel is destroyed when the connection ends. On the contrary, a passive socket doesn’t take part in any kind of connection, but waits for an incoming connection. Furthermore, when the passive socket is attached to an application it generates a new socket that is active.
An internet socket is recognized by transport protocol (e.g. UDP or TCP), remote socket address and the local socket i.e. port number and local IP address.
Image courtesy: forum.bodybuilding.com
It is a logical data connection which is used to exchange data files without using any kind of temporary storage or file. TCP and UDP are the most extensively used ports which are used to transfer data between PCs.
Additionally, it is recognised by using the transportation protocol, IP address and different numbers which are associated with the port - known as port number.
It is to be noted that the arrangement of port numbers is mostly reserved in a computer which is hosting the whole service. Besides, the process of connecting a group of ports which have a specific sequence, is known as port scanning.
Generally, the process of port scanning is deemed as malicious as it may damage the data files of the computer. Therefore, the administrators always keep an eye on the networking activities so as to protect it from any viruses or malicious software.
Image courtesy: commons.wikimedia.org