It’s more a question of design, than speed (Shared Memory is faster), domain sockets are definitively more UNIX-style, and do a lot less problems. In terms of choice know beforehand:
Domain Sockets advantages
- blocking and non-blocking mode and switching between them
- you don’t have to free them when tasks are completed
Domain sockets disadvantages
- must read and write in a linear fashion
Shared Memory advantages
- non-linear storage
- will never block
- multiple programs can access it
Shared Memory disadvantages
- need locking implementation
- need manual freeing, even if unused by any program
That’s all I can think of now. However, I’d go with domain sockets any day — not to mention that it’s a lot easier then to reimplement them to do distributed computing. The speed gain of Shared Memory will be lost because of the need of a safe design. However, if you know exactly what you’re doing, and use the proper kernel calls, you can achieve greater speed with Shared Memory.