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?

  • 1
    It should probably block the writer, just like with pipes.
    – PSkocik
    May 15, 2016 at 19:34
  • So in my example socat will block at some point? Can those sockets be driven non-blocking?
    – bot47
    May 15, 2016 at 19:35
  • 1
    AFAIK, on linux, you can set pretty much any filedescriptor that's normally blocking into nonblocking mode, either on creation (socket, open) or later with fnctl. In nonblocking mode, you get EAGAIN on operations that would otherwise block.
    – PSkocik
    May 15, 2016 at 19:39
  • Is this possible using command line tools or do I have to fire up my C compiler? When it's non-blocking, does it just drop the incoming data?
    – bot47
    May 15, 2016 at 19:42
  • 2
    If a tool is designed to work with a socket in non-blocking mode then it would set a socket appropriately and treat all exchanges in accordance with its design. You can't control externally how the tool would perform IO on a socket unless that tool provides you a way to control its behavior by means of its config file(s) or command line options
    – Serge
    May 15, 2016 at 22:08

1 Answer 1


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.

  • I wouldn't call that reliable, it's just what it is. By the way, the limit I got on Linux 4.4 x64 was 180 KiB.
    – bot47
    May 17, 2016 at 17:59
  • 5
    @MaxRied Unix sockets are reliable, as opposed so lossy. It means that they don't lose messages. May 17, 2016 at 21:08
  • 2
    Yes, all types of Unix domain sockets (datagram, stream and sequenced-packet) are reliable, in-order delivery mechanisms. That is, they don't drop data unless the receiver terminates or closes the connection without receiving the data first. Typically, they operate in blocking mode by default, but can be placed in non-blocking mode.
    – jtchitty
    Oct 19, 2017 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.