From: Ken Brown <kbrown@cornell.edu>
To: cygwin-developers@cygwin.com
Subject: Re: The unreliability of AF_UNIX datagram sockets
Date: Sat, 22 May 2021 14:21:47 -0400 [thread overview]
Message-ID: <14b72d6d-2896-e0ae-7040-d8755df66371@cornell.edu> (raw)
In-Reply-To: <00fdcf54-2506-0490-d174-3bef56311417@cornell.edu>
On 5/22/2021 12:50 PM, Ken Brown wrote:
> On 5/22/2021 11:49 AM, Corinna Vinschen wrote:
>> On May 21 17:54, Ken Brown wrote:
>>> On 5/20/2021 3:25 PM, Corinna Vinschen wrote:
>>>> On May 20 09:46, Ken Brown wrote:
>>>>> 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.
>>>>
>>>> Yeah, sounds like the way to go for now.
>>>
>>> Unfortunately, I ran into a problem. Trying to emulate DGRAM sockets in
>>> STREAM sockets breaks the DGRAM send/recv semantics. For example,
>>> WSARecvFrom won't return the source address.
>>
>> It doesn't anyway, does it? I mean, this is entirely local and the
>> source address is, basically, the same socket.
>
> From the Winsock point of view, the sending socket is an AF_INET socket, whose
> name is a struct sockaddr_in (the crucial data being the port number).
> fhandler_socket_local::recv_internal then converts the sockaddr_in of the sender
> to an abstract sockaddr_un that encodes the port number, so that the receiver
> can send back a reply.
Wait a minute.... I don't think this is a problem after all. The sender can
simply include its own address in the packet it sends, as in the new AF_UNIX code.
> Aside from this issue, there's also the fact that all the send/recv functions
> when applied to STREAM sockets expect the socket to be connected. But if we're
> using STREAM sockets to emulate DGRAM sockets, they typically won't be
> connected. (And "connected" means something different for DGRAMs anyway.)
But I'm still worried about this issue.
Ken
prev parent reply other threads:[~2021-05-22 18:21 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-27 15:47 Ken Brown
2021-04-29 11:05 ` Corinna Vinschen
2021-04-29 11:16 ` Corinna Vinschen
2021-04-29 14:38 ` Ken Brown
2021-04-29 15:05 ` Corinna Vinschen
2021-04-29 15:18 ` Corinna Vinschen
2021-04-29 16:44 ` Ken Brown
2021-04-29 17:39 ` Corinna Vinschen
2021-05-01 21:41 ` Ken Brown
2021-05-03 10:30 ` Corinna Vinschen
2021-05-03 15:45 ` Corinna Vinschen
2021-05-03 16:56 ` Ken Brown
2021-05-03 18:40 ` Corinna Vinschen
2021-05-03 19:48 ` Ken Brown
2021-05-03 20:50 ` Ken Brown
2021-05-04 11:06 ` Corinna Vinschen
2021-05-13 14:30 ` Ken Brown
2021-05-17 10:26 ` Corinna Vinschen
2021-05-17 13:02 ` Ken Brown
2021-05-17 13:02 ` Ken Brown
2021-05-20 13:46 ` Ken Brown
2021-05-20 19:25 ` Corinna Vinschen
2021-05-21 21:54 ` Ken Brown
2021-05-22 15:49 ` Corinna Vinschen
2021-05-22 16:50 ` Ken Brown
2021-05-22 18:21 ` Ken Brown [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=14b72d6d-2896-e0ae-7040-d8755df66371@cornell.edu \
--to=kbrown@cornell.edu \
--cc=cygwin-developers@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).