DEV Community


Posted on

What are sockets in computer networks?

Two processes that run on the same machine, or different machines, communicate through sockets. Sockets are seen as the end of the two-way communication between two processes; they allow processes to communicate with each other ​using a file descriptor and are commonly used in client-server applications that allow ​for ​communication between multiple applications.

How sockets are created

A socket is created by concatenating the IP number of a system and a software port number (not a ​hardware port number). This allows the process to know the address of the system (the IP address) and the address where the information needs to be sent (the port number). The IP number and the port number are separated by a ​:.
Alt Text
The diagram above shows two different applications communicating with one another through sockets.

In this diagram, application 1 sends the data to IP number of application 2, port 100, while application 2 sends the data to ​IP number of application 1, port ​80.

Top comments (0)