X-Spam-Check-By: sourceware.org
Date: Fri, 7 Apr 2006 17:56:53 -1000 (HST)
From: Antonio Querubin <tony@lava.net>
To: Dave Korn <dave.korn@artimi.com>
Cc: cygwin@cygwin.com
Subject: RE: getsockname problem
In-Reply-To: <001101c65a43$890d59a0$a501a8c0@CAM.ARTIMI.COM>
Message-ID: <Pine.BSI.4.61.0604071714520.4432@malasada.lava.net>
References: <001101c65a43$890d59a0$a501a8c0@CAM.ARTIMI.COM>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

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.

--
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/

