tags:

views:

1144

answers:

4

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.

+2  A: 

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

qrdl
+2  A: 

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.

caf
A: 

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.

mav
OP asked about domain sockets. Domain sockets usually implemented over pipes so they are as fast as pipes. Domain sockets are useful as they have exactly the same interface as network sockets (just different socket family) so if your application supports sockets and you found that both parties are located on the same computer, you can easily switch to domain sockets to speed things up (X Windows does it). So you answer is incorrect.
qrdl
hope it's updated well.
mav
+2  A: 

Just about any way two process 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
Robert S. Barnes