'What happens with messages that are being sent over a Unix socket while the receiving end is not reading from the socket?
I am currently learning about IPC and Unix domain sockets. I was wondering what happens with messages that are being sent over a Unix socket while the receiving end is not reading from the socket? Do they get sent regardless whether someone is reading or do they stay in some sort of queue waiting for a reader
Solution 1:[1]
Based on my research (Linux), in the case of datagram (message-oriented) Unix socket:
- if the receiving end has not done
bind()on the socket, the sender will fail to performsendto(); - if the receiving end has done
bind()on the socket and does not keep on doingrecvfrom(), the sender will enqueue a batch of messages up to some limit and stall; - if the receiving end resumes doing
recvfrom(), the sender will resume.
See also: sysctl net.unix.max_dgram_qlen (for queue size).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
