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 ​:.

svg viewer

The diagram above shows two different applications communicating with one another through sockets.

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

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved