The unreliability of AF_UNIX datagram sockets

Ken Brown
Thu May 20 13:46:44 GMT 2021

On 4/29/2021 7:05 AM, Corinna Vinschen wrote:
> I think it should be possible to switch to STREAM sockets to emulate
> DGRAM semantics.  Our advantage is that this is all local.  For all
> practical purposes there's no chance data gets really lost.  Windows has
> an almost indefinite send buffer.
> If you look at the STREAM as a kind of tunneling layer for getting DGRAM
> messages over the (local) line, the DGRAM content could simply be
> encapsulated in a tunnel packet or frame, basically the same way the
> new, boring AF_UNIX code does it.  A DGRAM message encapsulated in a
> STREAM message always has a header which at least contains the length of
> the actual DGRAM message.  So when the peer reads from the socket, it
> always only reads the header until it's complete.  Then it knows how
> much payload is expected and then it reads until the payload has been
> received.

I think I'd like to go ahead and try to do this DGRAM emulation in the current 
(AF_LOCAL) code.  It shouldn't be too hard, and it would solve the unreliability 
problem while we look for a better way to handle AF_UNIX sockets.


More information about the Cygwin-developers mailing list