4 ms·
How does SOCK_SEQPACKET simplify fd-passing? Writing a streaming IPC crate as we speak and wondering if there are land mines beyond https://gist.github.com/kent
by chadaustin 3y ago
How does SOCK_SEQPACKET simplify fd-passing? Writing a streaming IPC crate as we speak and wondering if there are land mines beyond https://gist.github.com/kentonv/bc7592af98c68ba2738f4436920868dc https://gist.github.com/kentonv/bc7592af98c68ba2738f44369208...
- the8472 3y agoWell, the kernel does create implicit packetization boundary when you attach FDs to a byte-stream... but this is underdocumented and there's an impedance mismatch between byte streams and discrete application-level messages. You can also send zero-sized messages to pass an FD. with byte streams you must send at least one byte. Which means you can send the FDs separately after sending the bytes which makes it easier to notify the application that it should expect FDs (in case it's not always using recvmsg with an cmsg allocation prepared). SEQPACKET just makes it more straight-forward because 1 message (+ancillary data) is always one sendmsg/recvmsg pair.
- chadaustin 3y agoI appreciate your reply! My approach has been to send a header with the number of fds and bytes the next packet will contain, and the number of payload bytes is naturally never 0 in my case.