IPC (Inter-process communication) involves communication between processes running either on the same machine or on different machines. It can be achieved through various methods such as:
Shared memory is a type of IPC mechanism where multiple processes can access the same physical memory address space. It utilizes mechanisms such as pipes, queues, and sockets for communication between processes within the same machine.
Pipe()
creates a communication channel (pipe) between two processes. Each process has one end of the pipe.
Figure 6.1 Pipe.
When using Pipe()
, two Connection objects (conn1
and conn2
) are returned.
It allows the transfer of structured data between processes.
send()
and recv()
data between processes.send()
and the other recv()
data.Queue()
provides a shared queue abstraction for inter-process communication, enabling multiple processes to exchange structured data.
Figure 6.2 Queue.
The queue facilitates the transfer of structured data between processes and supports three variants: