cpuer
cpuer

Reputation: 7793

Inter process communication on the same machine,signal or socket,how to decide?

It seems to me that both signal and socket can be used for this job,

how do you decide which one to use actually?

Upvotes: 0

Views: 2172

Answers (1)

Blagovest Buyukliev
Blagovest Buyukliev

Reputation: 43508

Using signals for IPC is sort of inconvenient and primitive. You should really be choosing between Unix sockets (not TCP ones!) and pipes.

Pipes are generally easier to program with, since they guarantee that a single write under the size of PIPE_BUF is atomic. They do have their limitations however. For example, when the writer is faster than the reader, the writer starts to block when the pipe buffer gets full. The size of this buffer by default is around 64k, and it cannot be changed without recompiling the kernel, at least in Linux. Pipes are also unidirectional, which means that you'll have to keep a pair of pipes in each process, one for reading and one for writing.

Unix sockets have a configurable send buffer size and a more advanced programming interface.

Upvotes: 6

Related Questions