How Processes Communicate

Let’s quickly examine the technical side of how processes Communicate.

Program vs. Process vs. Thread

The terms “process” and “application” have been informally used to mean the same thing. Let’s now define it more precisely.

  • Simply put, an executable file is a program. One example is a program like Microsoft Word.
  • Any instance of a program that is open and executing is a process. Multiple instances of a single software may thus be executed at once. Microsoft Word programs may have several windows active at once.
  • A thread is a simple operation. Multiple threads may be active inside a single process. The fact that threads perform specialized, lightweight tasks separates them from processes.
Developer Working

On the same computer, processes may and often do interact with one another according to the operating system’s (OS) guidelines. But what interests us more is the communication between processes that are running on several computers.

Sockets

Through the computer network, processes running on various computers communicate with one another. A socket is the name of the connection point between a process and the computer network. Keep in mind that sockets are software interfaces and have nothing to do with hardware.

Processes don’t care about it after that; they just route their communications to sockets.

Addressing

The recipient of messages must be a specific application on a certain end system. With possibly millions of end systems and hundreds of apps running on each one, how is this accomplished?

It’s accomplished using addressing structures like IP addresses and ports.

Ports

Ports are used to address the packet to certain apps since each end-system may execute a number of different applications. Some ports, like port 80 for HTTP and port 443 for HTTPS.

An application’s creators often predetermine the port that it will utilize. So, a port 3000 may be set aside for a certain application. But what happens when many instances (processes) of an application are active simultaneously? How is the system going to handle such procedures?

Ephemeral Ports, therefore, hold the key to the solution. Dynamically generated port numbers are used for each instance of a program. Once the program has finished utilizing the port, it is released.

Additionally, in order for clients to connect to server processes in a methodical and predictable manner, such processes must have well-defined and stable port numbers. Clients do not need to have reserved ports, however. Ephemeral ports are a possibility.

In addition to the reserved ports, servers may also utilize ephemeral ports. One example is when a client first connects to the server on a well-known port and then continues communicating with the server by connecting on an ephemeral port.

Gaurav Karwayun is the founder and editor in chief of CodeIntelligent. He has over 10+ Years of Experience in the software industry. He has experience working in both service and product-based companies. He has vast experience in all popular programming languages, DevOps, Cloud Computing, etc. Follow him on Twitter.

Leave a Comment