简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM