delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/04/11/05:28:18

X-Spam-Check-By: sourceware.org
Date: Tue, 11 Apr 2006 11:28:09 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: getsockname problem
Message-ID: <20060411092809.GB31165@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <001101c65a43$890d59a0$a501a8c0 AT CAM DOT ARTIMI DOT COM> <Pine DOT BSI DOT 4 DOT 61 DOT 0604071714520 DOT 4432 AT malasada DOT lava DOT net>
Mime-Version: 1.0
In-Reply-To: <Pine.BSI.4.61.0604071714520.4432@malasada.lava.net>
User-Agent: Mutt/1.4.2i
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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

On Apr  7 17:56, Antonio Querubin wrote:
> On Fri, 7 Apr 2006, Dave Korn wrote:
> 
> > Should have read the man page instead!
> >
> >>   s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
> >>   printf("socket = %d\nlength = %d\n", s, len);
> >>
> >>   rc = getsockname(s, (struct sockaddr *) &sa, &len);
> >
> >
> >http://www.opengroup.org/onlinepubs/007908799/xns/getsockname.html
> >
> >"If the socket has not been bound to a local name, the value stored in the
> >object pointed to by address is unspecified."
> 
> This doesn't explain why the code fragment works under UNIX and Linux 
> systems (that I have access to), but fails under Cygwin.
> 
> According to Steven's 'Unix Network Programming', 2'd edition, Vol 1, 
> "Posix.1g allows a call to getsockname() on an unbound socket". 
> Furthermore, the Cygwin API indicates Cygwin's networking support is 
> standardized to Posix.1g for getsockname() and a whole bunch of the other 
> networking functions.

We can't create a local name for the socket if the underlying getsockname
function in WinSock doesn't.  Apparenty WinSock doesn't.  Which should be
no problem since the behaviour is still conformant to the standards.
Note that Posix 1.g allows to return a local name, it doesn't demand it.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

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

- Raw text -


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