X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C46DF386FC22 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1627598533; bh=c8hYfUJfI/uH0biJJdewGI6+1SnbksgWvTLTbByKyRs=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=psoiCrwkONOLpjS5Q9dYcWaAEBEY8x+nj1B8ccpWMNCqCX2bOE30a0roGJfiCcAWO Uf7MnNc4tBuo4EF2UOBt7NSnxvDj/6NAEPpp26rAPCYT+X7cKAU7Zf2fEHOZTMbrxX pB4x+9Mx3RkxTCi+6z7xt2Ffx3MQmiq+HjZLzE+Y= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 10E72384780D Message-ID: <1f5c0302c156c9391d294ea9df84d93b8742a500.camel@posteo.net> Subject: calls to socket() fail when calling getaddrinfo() with IPPROTO_TCP To: cygwin AT cygwin DOT com Date: Thu, 29 Jul 2021 22:41:30 +0000 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, 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 AT cygwin DOT com X-Mailman-Version: 2.1.29 List-Id: General Cygwin discussions and problem reports List-Archive: List-Post: List-Help: List-Subscribe: , From: John Scott via Cygwin Reply-To: John Scott Content-Type: multipart/mixed; boundary="===============7042071369473644236==" Sender: "Cygwin" --===============7042071369473644236== Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-kHAtm/0iVaHTPFWjeQA0" --=-kHAtm/0iVaHTPFWjeQA0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, I was wondering why my daytime server doesn't work when built for Cygwin, and I have been able to narrow it down to this reproducible test case: #define _POSIX_C_SOURCE 200809L #include #include #include #include #include #include #include int main(void) { struct addrinfo *res; int s =3D getaddrinfo(NULL, "daytime", &(const struct addrinfo){.ai_flags = =3D AI_PASSIVE, .ai_protocol =3D IPPROTO_TCP}, &res); if(s) { fprintf(stderr, "Failed to get address info: %s\n", (s !=3D EAI_SYSTEM) ?= gai_strerror(s) : strerror(errno)); exit(EXIT_FAILURE); } for(const struct addrinfo *tmp =3D res; tmp; tmp =3D tmp->ai_next) { int fd =3D socket(tmp->ai_family, tmp->ai_socktype, tmp->ai_protocol); if(fd =3D=3D -1) { perror("Failed to create socket"); } else if(close(fd) =3D=3D -1) { perror("Failed to close socket"); } } freeaddrinfo(res); } This code fails with "Failed to create socket: Invalid argument". Does anyone have an idea why this happens, given that the arguments to socket() come directly from the call to getaddrinfo()? Remarkably, changing the service from "daytime" to "http" seems to fix it, which seems quite strange. I'm not subscribed, so please CC me on replies. --=-kHAtm/0iVaHTPFWjeQA0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iIgEABYKADAWIQT287WtmxUhmhucNnhyvHFIwKstpwUCYQMumxIcanNjb3R0QHBv c3Rlby5uZXQACgkQcrxxSMCrLacqfAEAn42r9/urCdv7GYK/eXlHRRdcuP8QE9Xl v1OfgwAOOJcBAISTAPUYYg60A0gJ4Y+q3zTWxSV7Uyforbq9NNb/8BcH =H7UE -----END PGP SIGNATURE----- --=-kHAtm/0iVaHTPFWjeQA0-- --===============7042071369473644236== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple --===============7042071369473644236==--