From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Cc: John Scott <jscott@posteo.net>
Subject: Re: calls to socket() fail when calling getaddrinfo() with IPPROTO_TCP
Date: Fri, 30 Jul 2021 12:47:39 +0200 [thread overview]
Message-ID: <YQPYy+L7KnFXnpOs@calimero.vinschen.de> (raw)
In-Reply-To: <YQPHquBoiwj50IdF@calimero.vinschen.de>
On Jul 30 11:34, Corinna Vinschen via Cygwin wrote:
> Yeah, that's a bad joke as well. The reason is that the http service is
> defined for TCP only. Not for UDP. As a result, Windows' getaddrinfo
> suddenly returns a valid ai_socktype field:
>
> family: 23 socktype 1 protocol 6 AF_INET6, STREAM, TCP
> family: 2 socktype 1 protocol 6 AF_INET, STREAM, TCP
Just to be precise here, the fact that ai_protocol is IPPROTO_TCP
in this example output is only because of your hints. If you don't
restrict ai_protocol, you'll get:
family: 23 socktype 1 protocol 0 AF_INET6, STREAM, any
family: 2 socktype 1 protocol 0 AF_INET, STREAM, any
> Cygwin implements a shallow (~300 lines) wrapper over the WinSock
> GetAddrInfoW function and otherwise relies on the values returned by the
> OS. However, it already duplicates the returned list to self-allocated
> memory, which is required for fork(2) semantics. It should be possible
> to improve the wrapper to duplicate entries with socktype and protocol
> 0-entries, but that would be in the next Cygwin version earliest.
I hacked up a patch which is supposed to do exactly that. In your case
it now returns
family: 23 socktype 1 protocol 6
family: 2 socktype 1 protocol 6
and in case you omit the ai_protocol restriction it returns with
family: 23 socktype 1 protocol 6
family: 23 socktype 2 protocol 17
family: 2 socktype 1 protocol 6
family: 2 socktype 2 protocol 17
rather than with
family: 23 socktype 0 protocol 0
family: 2 socktype 0 protocol 0
I've uploaded a new developer snapshot to https://cygwin.com/snapshots
Please give it a try and report back.
Thanks,
Corinna
next prev parent reply other threads:[~2021-07-30 10:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-29 22:41 John Scott
2021-07-30 9:34 ` Corinna Vinschen
2021-07-30 10:47 ` Corinna Vinschen [this message]
2021-07-30 11:02 ` John Scott
2021-07-30 16:44 ` Brian Inglis
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=YQPYy+L7KnFXnpOs@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin@cygwin.com \
--cc=jscott@posteo.net \
/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).