delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/01/13/16:39:49

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:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=eYiXmu5JYqU+3jne
vSEQTFPDYbbqVGKVtJWa/1/eJnIlQJXGczgty8juHQFmBMHJ7KO7Gdb9jgadXZg9
ItKGsd+uPr3pSdNegvuX42bi64r/o4e11nUIsjMuKICSCSPLI896uqCkEDz8WS/O
LvZfIbPWOC2YM3Ke9zpdkuCwpsM=
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:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=FxODyZNxWUSI1ny99XWXHh
gkJW8=; b=pF660ZOiWFO4gMoip2ozQvcB9bnGXMg4QSnEhY7Q/7Tilui1s0ixpX
TANO6LRolce4FF7Ld7kQ6MnDIaY3bIoDx1duDuq7zMO5KMUZWp/hchkzeYdyYpsu
twxubA1/JTPIVlU/Vcy+u1nS+0zWd/8GFIKNtP5WGMbsEQS/nqzwY=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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=-0.9 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=Miss, Hx-languages-length:3332, H*u:6.1, H*UA:6.1
X-HELO: m0.truegem.net
Subject: Re: Cygwin socket option SO_REUSEADDR operates unlike Linux
To: cygwin AT cygwin DOT com
References: <Pine DOT BSF DOT 4 DOT 63 DOT 1801122348420 DOT 62607 AT m0 DOT truegem DOT net> <20180113135127 DOT GA22225 AT calimero DOT vinschen DOT de>
From: Mark Geisert <mark AT maxrnd DOT com>
Message-ID: <e072e320-fca4-582d-508e-91c5c0d78bc6@maxrnd.com>
Date: Sat, 13 Jan 2018 13:39:28 -0800
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0 SeaMonkey/2.46
MIME-Version: 1.0
In-Reply-To: <20180113135127.GA22225@calimero.vinschen.de>

Corinna Vinschen wrote:
> 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 September
>> but are unfortunately not chained together...  They contain a discussion
>> I've been having with OP Raimund Paulus.
>>
>> 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.
>>
>> On the latest 64-bit Cygwin, running the STC shows:
>>
>> ~ 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               *:*
>>
>> ~ ./bindtest
>> 1st socket is 3
>> 1st bind OK
>> 1st connect OK
>> 2nd socket is 3
>> 2nd bind OK
>> 2nd connect: Address already in use
>>
>> ~ ./bindtest
>> 1st socket is 3
>> 1st bind OK
>> 1st connect: Address already in use
>>
>> On Fedora 27, running the same STC shows:
>>
>> [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
> tcp6       0      0 :::111                  :::*                    LISTEN
> udp        0      0 0.0.0.0:111             0.0.0.0:*
> udp6       0      0 :::111                  :::*
> $ ./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."

Rats.  I'll have to investigate a couple of directions, deeper.  It makes sense 
that connect() returns EADDRINUSE rather than bind() because only connect() 
knows about all 5 parts of the 5-tuple.  Stevens is/was the definitive network 
software guy.  Miss him.  Most accounts I've found deal with SO_REUSEADDR on the 
server side, not the client side, so my intuition is a bit faulty.

Thanks for your time, Corinna.  Raimund: I'll have to do some more digging when 
I get back to a keyboard in a week or so.  Sorry for the delay on this.  There 
might be some issue inside libtirpc where it botches error returns from the 
kernel.  Or something.

Thanks all,

..mark


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019