From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.74]) by sourceware.org (Postfix) with ESMTPS id 2B68D3851C33 for ; Fri, 30 Jul 2021 10:47:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2B68D3851C33 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MuUrM-1mzSdr01iM-00raDo; Fri, 30 Jul 2021 12:47:41 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id DAE53A80DEF; Fri, 30 Jul 2021 12:47:39 +0200 (CEST) Date: Fri, 30 Jul 2021 12:47:39 +0200 From: Corinna Vinschen To: cygwin@cygwin.com Cc: John Scott Subject: Re: calls to socket() fail when calling getaddrinfo() with IPPROTO_TCP Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com, John Scott References: <1f5c0302c156c9391d294ea9df84d93b8742a500.camel@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K1:6DX2D42HH41pBE5aBCZdUoXxQFkMIerlj6KCv4z/neA33TPsSsS AVNLFHHJSfr6XGvYht38V6yMbgXtpptglg3GjclLW6zno5MajaJzkvGjxA+sWnKnkSouNtJ IxiLZa6qnwYL0gpoSwy+aEWNR00ddUG60S7qSkdhAo7W5Ot7uJmcZT/xSkYfXEBjrh4HEvJ xFDadRbgruAyRgIkA2zXQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:wG86dk/IYOU=:JOBFiigql3CMBgYOXB6nnt GTVOm/8Wa/PvdpumLdy4+tId6kTVRgDZmKI7fQ9ArbYisNDH3zQvzC4Ww7s9DpWqct/gaRJMc /jE92CQFRVWPdwJjTKjT0xNUugEm5enSDyJvhF/NV22LTxqlAm952ukVwSGeccTrdtFuap3OV BU2IRLSzq7+hcv+4lyAlGSMvD6WQnqscRsBUd2lFxE7vozLYM6lYyOXdeRxgeflwygLOgDUm/ LqsMO0ILhtT6uacSrlJlI10Z/8stu8DU2Vob+I9aGv5o4Y2bEM71tHzdxGD6dppUhwEHQCnEL ZeY00MtCzKsnZiwVSCQ8ByGLQWO2hLwJX1hoVMi/VialZT/vT6fzkruJW/W8dsCEAqMQmHh/e NrQnpaRo6HHXjlEAykAPPFVRlnopS+Yt0y/RjdULHffIcyO2CVpECQs43Jfdjo9wb/5krT4vY MmRBJQIWSLHA3TG3CBshRLNxPd/ZFeyqNDIVW5IefFJ5zYsKSQCpoqB8DccUNLCzci0DZ0+Vk Atarne+JXgoJaXFYeDq3wiK9ra+aqHhSuk+YBPxPDMqJGsQpVHGyBVrJWOGdvEvrRBEiqTpvO I6Ks6bBTco47Z2XUG/SIgLaMjutGYNFTIlECkf0Htc+q+PI0ThjjlRgl/cSEmZH0qsv5XCIIt 1dvXBVYYvRkC5R1ca6Fw+92afCU6AQYHD8mr4WUhIQPf8fLHs9aYQV8SLMBBqJfR5sT9X9taK VNIIONdRYUg8YbLMClVIvJUTqFhb/MWh2Dg1oNl+1wRJX2KdSremHnRvyIJZ7/kzEwiLYGHBJ 2sbDSrULWFgHsYdN4JIkUbfYkby9tC7zjKYT8XIu7uGek7X6hMY0kL5lqVEclOjFjLw+dOCIG ZThR/CnDneB+oW14Jeww== X-Spam-Status: No, score=-100.2 required=5.0 tests=BAYES_00, GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jul 2021 10:47:44 -0000 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