Search code examples
socketsunixpublish-subscribe

What methods are available on unix for pub sub IPC?


There are various options for IPC.

Over a network:

  • for client-server, can use TCP
  • for pub sub, can use UDP multicast

Locally:

  • for client-server, can use unix domain sockets
  • for pub sub, can use ???

I suppose what I'd be interested in is some kind of file descriptor that supports many readers (subscribers) and many writers (publishers) simultaneously. Is this usage pattern feasible/efficient on unix?


Solution

  • After much googling I haven't found a whole lot in the way of ipc multicast, so I have decided to write a program pubsub that takes as arguments a publisher address and a subscriber address, listens and accepts connections on these 2 addresses, and then for each payload received on a publisher connection write it to each of the subscriber connections. It wouldn't surprise me if this is inefficient or reinventing the wheel but I have not come across a better solution.