delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/04/07/08:41:27

X-Spam-Check-By: sourceware.org
Message-ID: <44365DE8.4070008@ateb.com>
Date: Fri, 07 Apr 2006 08:41:12 -0400
From: Reid Thompson <reid DOT thompson AT ateb DOT com>
Reply-To: reid DOT thompson AT ateb DOT com
User-Agent: Thunderbird 1.5 (Windows/20051201)
MIME-Version: 1.0
To: Antonio Querubin <tony AT lava DOT net>, cygwin AT cygwin DOT com
Subject: Re: getsockname problem
References: <Pine DOT BSI DOT 4 DOT 61 DOT 0604070121530 DOT 9018 AT malasada DOT lava DOT net>
In-Reply-To: <Pine.BSI.4.61.0604070121530.9018@malasada.lava.net>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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

Antonio Querubin wrote:
> I've run into a problem where getsockname() doesn't work as expected. 
> Below is a test program where it fails under cygwin but runs on any 
> other Unix/Linux system.  I searched the mail archives for any 
> limitations
>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <netinet/in.h>
> #include <stdio.h>
>
> int main() {
>
>   struct sockaddr_in sa;
>   socklen_t len = sizeof sa;
>   int s, rc;
>
>   s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
>   printf("socket = %d\nlength = %d\n", s, len);
>
>   rc = getsockname(s, (struct sockaddr *) &sa, &len);
>   printf("getsockname rc = %d\nreturned length = %d\n", rc, len);
>   perror("getsockname");
>
>   return rc;
>
> }
well,,, not 'any' other linux system...

$ ./getsockname
socket = -1
length = 16
getsockname rc = -1
returned length = 16
getsockname: Bad file descriptor

[rthompso AT wasteland /home/rthompso
$ uname -a
Linux wasteland 2.4.18-18.7.x #1 Wed Nov 13 20:29:30 EST 2002 i686 unknown

similar failed response on WinXP
$ ./getsockname
socket = 3
length = 16
getsockname rc = -1
returned length = 16
getsockname: Invalid argument
WS-XP-4960[08:38:46]: /home/rthompso>


perhaps a re-coding is in order...




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