X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; q=dns; s= default; b=AkZezj/SGcEcSqWOUbOVNFWHq39ar2vet7fv01kr1tKicjsZ+luMS 9pYlgGvcEWHQstbF1R4bfUSthyhGEmEtFlHO4JIXRoOlzMQkVSX/8nxlTjGFqhhk jR2EHZ9sN5o6AJwk5ycQ8Fkt6Hk9tny4+jyI1B9cesroSWqjfsXCjA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; s=default; bh=SoYGirvsY4qx1XrIk1ardPl/0Rg=; b=Go1QwaH2qqJKftQ4lSMa+IXz7Z5P 7QLY0gR84BUfPx5zPIc9ZKaGAK7jhlbD9Hes07TuFa2Se00smiaiVrMtxQCtAtUy SN9lWAkMTND5KZCLJ+bNE86rE/MvpwnBv6qwUcHiRLauQ4ANJRtyzKyfLgyvzRrJ yQprZwmd9vLBUco= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-100.3 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_BRBL_LASTEXT,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Network, himself, networking, Networking X-HELO: drew.franken.de Date: Sat, 13 Jan 2018 14:51:27 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: Cygwin socket option SO_REUSEADDR operates unlike Linux Message-ID: <20180113135127.GA22225@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="FCuugMFkClbJLl1L" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) --FCuugMFkClbJLl1L Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Jan 13 00:36, Mark Geisert wrote: > This report is based on a series of recent list emails with Subject: lines > "RPC clnt_create() adress already in use" which date back to last Septemb= er > but are unfortunately not chained together... They contain a discussion > I've been having with OP Raimund Paulus. >=20 > I believe I've distilled the issue(s) down as far as I can. A > self-contained STC is included at the end of this email. >=20 > On the latest 64-bit Cygwin, running the STC shows: >=20 > ~ netstat -an|grep :111 > TCP 0.0.0.0:111 0.0.0.0:0 LISTENING > TCP [::]:111 [::]:0 LISTENING > UDP 0.0.0.0:111 *:* > UDP [::]:111 *:* >=20 > ~ ./bindtest > 1st socket is 3 > 1st bind OK > 1st connect OK > 2nd socket is 3 > 2nd bind OK > 2nd connect: Address already in use >=20 > ~ ./bindtest > 1st socket is 3 > 1st bind OK > 1st connect: Address already in use >=20 > On Fedora 27, running the same STC shows: >=20 > [mark AT lux ~]$ netstat -an|grep :111 > tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN > tcp6 0 0 :::111 :::* LISTEN > udp 0 0 0.0.0.0:111 0.0.0.0:* > udp6 0 0 :::111 :::* > [mark AT lux ~]$ ./bindtest > 1st socket is 3 > 1st bind OK > 1st connect OK > 2nd socket is 3 > 2nd bind OK > 2nd connect OK I can't reproduce this: $ uname -sr Linux 4.14.13-300.fc27.x86_64 $ netstat -an|grep :111 tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN= =20=20=20=20=20 tcp6 0 0 :::111 :::* LISTEN= =20=20=20=20=20 udp 0 0 0.0.0.0:111 0.0.0.0:*=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 udp6 0 0 :::111 :::*=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 $ ./bindtest 1st socket is 3 1st bind OK 1st connect OK 2nd socket is 3 2nd bind OK 2nd connect: Cannot assign requested address I tried this a couple of times even as root, just to be sure, but the result is invariable "2nd connect: Cannot assign requested address". The error message is different from Cygwin, but the overall behaviour is the same for me, and it matches the comment I wrote in cygwin_setsockopt back in 2009 and 2011. I'm very puzzled that it works for you. As I wrote in my comment, a complete duplicate of a local TCP address is not allowed, regardless of SO_REUSEADDR. If I may quote Mr. Network himself, the late W. R. Stevens, "UNIX Network Programming, Networking APIs: Sockets and XTI", Volume 1, 2nd Edition. Section 7.5: "With TCP we are never able to start multiple servers that bind the same IP address and the same port: a 'complete duplicate binding'. That is, we cannot start one server that binds 198.69.10.2 port 80 and start another that also binds 198.69.10.2 port 80, even if we set the SO_REUSEADDR soocket option for the second server." Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --FCuugMFkClbJLl1L Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlpaDt8ACgkQ9TYGna5E T6DrchAAiEAAAA1KnZUtB8W3Tb+KvXRScRizYMU9ac8/Z5BQcILDiQGrmTR8/qOd 42jblSPrIRkG4P1qVzML/LxH28HqKVpN9Q6z6i3XfafXJoEyOihC/jLQk5S22v0B cfuISfORTqEiPC6ezq01AxIqdzIIQY2mbaog7v6N6wQqEn87BWTeqUXhSjdAQX0N yUlXoQ/2JoJN++FXs9C3IZyD1jtxknwvAwqY407VKCyxI+R21+mustKyldWt/1bm VwwZ2pu17nQbZ4Of41KcfoLKFyniPSRisPp5knAzF9VUjrB8V0MFt20qZVb7KYEV a6MygQlpWIuzzZo2CNQk26exIdkcOFJJGg79pG09yJ3zQP++JM2Znf9sDbHqj5d7 WxmQBVCENsCRGQpPftqQx2qiBeiyoApN/vwuxKklJAdhw5bGrAS1lcB8IiAjj5iV e7ZIu9mjge5Ho9kFpA6W0tz4Rjo3WxA3M0OkeE/lkWICslHiOk0e4hrlbzVOADIZ Ws2FPLsBlC+43a0+n5HC/eG38eP0LJx//YQ+tDlZhyE6GK6CEe/zQNDZSwzHaCXP +TeJVhVH2bUQLczfkqAJTvGKHneW+w1r8SmdZx3XRXHvbPjAWVia47bNGIufJ8WM I2E5nXiJP50PP9KR06sQyy88kuCU3fE53B/hBAq1Sg7ikgH0T5k= =X6Cc -----END PGP SIGNATURE----- --FCuugMFkClbJLl1L--