Do UNIX Domain Sockets Overflow

unix-sockets

When you create a UNIX socket using socat and send data to it, but do not have another socat instance connecting to that socket, what will happen then?

What happens if you write massive amounts of data to a UNIX socket and never read it? Is there a buffer that overflows? Is it ring-buffered?

Best Answer

Unix sockets are reliable. If the reader doesn't read, the writer blocks. If the socket is a datagram socket, each write is paired with a read. If the socket is a stream socket, the kernel may buffer some bytes between the writer and the reader, but when the buffer is full, the writer will block. Data is never discarded, except for buffered data if the reader closes the connection before reading the buffer.

Related Question