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
CodePudding user response:
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 receiveing 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).