Search code examples
linuxsocat

Does socat support SOCK_SEQPACKET for Unix domain socket?


Consider the following setup where one instance of socat pipes data from stdin to a unix domain socket, and the other instance reads that data from the unix domain socket and writes it to stdout:

Client:

(while true; do echo "hello"; sleep 1; done) | socat STDIN UNIX:test.sock

Server:

socat UNIX-LISTEN:test.sock STDOUT

This setup works as expected, where the server prints hello to stdout at an interval of 1 second. Is there a way with socat to use the SOCK_SEQPACKET socket type?


Solution

  • Upon further investigation of the man page, I learned that SOCK_SEQPACKET is supported by socat:

    socktype= Sets the type of the socket, specified as second argument to the socket() or socketpair() calls, to [int]. Address resolution is not affected by this option. Under Linux, 1 means stream oriented socket, 2 means datagram socket, 3 means raw socket, and 5 seqpacket (stream keeping packet boundaries).

    Client:

    (while true; do echo "hello"; sleep 1; done) | socat STDIN UNIX:test.sock,socktype=5
    

    Server:

    socat UNIX-LISTEN:test.sock,socktype=5 STDOUT