Question

Whats the different between IPC and Unix domain sockets and named pipes?

I got vague definitions from various books but couldn't get clarity on which one should be used where.

Was it helpful?

Solution

Just about any way two processes communicate with each other could be considered a form of IPC.

For example:

  1. Unnamed Pipes ( cat file.txt | grep foo ) or Named Pipes
  2. Unix Domain Sockets
  3. TCP or UDP sockets
  4. Netlink Sockets on Linux
  5. Various Shared Memory Mechanisms such as Memory Mapped Files
  6. High Speed Message Passing such as ZeroMQ

OTHER TIPS

As qrdl stated, UNIX-domain sockets and named pipes are both IPC mechanisms.

Of these two, named pipes are simpler to work with, but much less flexible than UNIX-domain sockets. For example, if you potentially expect more than one reading process for each writing process, then UNIX-domain sockets are a must; if you expect the reading process to stop and start during the execution of the writing process, then you'll need UNIX-domain sockets.

IPC stands for Inter-Process Communications. UNIX domain sockets and named pipes are just two IPC mechanisms, described in Wikipedia:

Thanks for focusing to the question, few updated features:

In Domain sockets, actual communication (the data exchange) does not use the file system, but buffers in kernel memory. By default, it is full-duplex mode.

Named pipes are identified by their access point, a file kept on the file system for handling the data. A named pipe by default supports blocked read and write operations. However, it is possible to make named pipes support non-blocking operations by specifying the O_NONBLOCK flag while opening them. A named pipe must be opened either read-only or write-only. It must not be opened for read-write because it is half-duplex,a one-way channel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top