UNIX Message Queues vs. Sockets

If I use sockets for IPC, and can easily distribute my applications.
UNIX Message Queues are local to the processor.

As I understand it, Message Queues still incur system call overhead, just like socket calls.

What advantage does a UNIX Message Queue provide versus a TCP or UDP Socket, and when should they be used?

There are two flavors of message queues... the old System V version (msgsend(), msgget(), etc) and the newer Posix version (mq_send(), mq_recieve(), etc). The Posix version is newer and more efficient.

Someone must be listening to a socket or you can't use it. A message queue stores the data until some process reads it. This could be minutes or hours later. Also you could have several processes take turns reading a message queue...like the tellers at a bank taking the next customer from a common queue. If the queue gets too long, add another teller at the bank or another instance of a server process on your system.

zen,

i doubt if you could use select() for the the different message queues, while you can do that for sockets. If you have multiple sockets and need to do event based handling depending on which socket you recv and what type of message you get, sockets are the ay to go. But the point to note is that its reliable, if you are pushing UDP packets internally within the system.