Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPC vs domain sock vs named pipes

Tags:

c

system

ipc

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.

like image 472
Jack Avatar asked Sep 12 '09 06:09

Jack


People also ask

Are named pipes faster than sockets?

The named pipe transmitted at a speed of 318 Mbits/s, while the UNIX socket transmitted at 245 Mbits/s. So, in relative terms, named pipes are approximately 30% faster than UNIX sockets with a block size of 100 bytes.

What is the difference between a socket and a pipe?

A socket pair is much like a pipe; the main difference is that the socket pair is bidirectional, whereas the pipe has one input-only end and one output-only end (see Pipes and FIFOs).

What is the difference between named pipe files and socket files?

What is the difference between socket and pipe? A socket is a part of the OSI model that enables communication between different layers. Pipes are used in processing in the CPU. Communication in socket is bi directional while it's unidirectional in pipes.

Is IPC faster than HTTP?

IPC based communication between local processes on an Android based mobile device (implementation platform for the prototype MCxB) is an order of magnitude faster and less resource intensive than HTTP based communication between the processes ( Kiani et al., 2011 ).


2 Answers

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
like image 55
Robert S. Barnes Avatar answered Oct 01 '22 11:10

Robert S. Barnes


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.

like image 21
caf Avatar answered Oct 01 '22 13:10

caf