delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/10/13/02:50:49

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
Message-ID: <416CC913.8040103@hq.astra.ph>
Date: Wed, 13 Oct 2004 14:20:03 +0800
From: Carlo Florendo <list-subscriber AT hq DOT astra DOT ph>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040616
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: other services ok, ftp not (was 1.5.11 - tcp problems)
References: <4745850620 DOT 20040921112624 AT scenta DOT co DOT uk> <416B3A95 DOT 4010506 AT hq DOT astra DOT ph> <Pine DOT GSO DOT 4 DOT 61 DOT 0410121150090 DOT 24643 AT slinky DOT cs DOT nyu DOT edu> <416C92BD DOT 90100 AT hq DOT astra DOT ph> <416CC006 DOT 3D4ECDEF AT dessent DOT net>
In-Reply-To: <416CC006.3D4ECDEF@dessent.net>
X-IsSubscribed: yes

Hello Brian,

Brian Dessent wrote:

>Carlo Florendo wrote:
>
>  
>
>>File:  inetutils-1.3.2-28 /ftp/main.c  (line numbers preceed each line)
>>
>>147     sp = getservbyname("ftp", "tcp");
>>148     if (sp == 0)
>>149         errx(1, "ftp/tcp: unknown service");
>>    
>>
>
>Okay, so the 'SYSTEM' thing was a red herring, and you're just running
>this from a normal command prompt.  Your SYSTEMROOT is set 
>
absolutely.

>and nothing
>seems odd in your cygcheck, and permissions on the "services" file seem
>okay.  Although I think your reasoning there is a little off-base:
>Cygwin itself does not attempt to access that file at all.  Cygwin's
>getservbyname() just a straight passthru to the Winsock function of the
>same name which does the actual lookup.
>  
>
Ok. thanks for the info.

>Try the following and see what happens:
>
>cat <<ENDL >getservbyname.c && \
>    gcc getservbyname.c -o getservbyname && ./getservbyname
>#include <stdio.h>
>#include <stdlib.h>
>#include <string.h>
>#include <errno.h>
>#include <netdb.h>
>#include <netinet/in.h>
>
>int main(int argc, char *argv[])
>{
>    struct servent *sv = getservbyname("ftp", "tcp");
>    
>    if(sv)
>        printf( "getservbyname() returned port %hu\n",
>            ntohs(sv->s_port));    
>    else
>        printf( "getservbyname() returned NULL: %s\n",
>            strerror(errno));    
>}
>ENDL
>  
>

Here's what I got:

getservbyname() returned NULL: Operation not permitted


>Also try the following variant that will create a mingw version of the
>same test:
>
>
>cat <<ENDL >getservbyname-mingw.c && gcc -mno-cygwin \
> getservbyname-mingw.c -o getservbyname-mingw && ./getservbyname-mingw
>#include <stdio.h>
>#include <stdlib.h>
>#include <string.h>
>#include <errno.h>
>#include <winsock2.h>
>
>int main(int argc, char *argv[])
>{
>    struct servent *sv;
>    WORD wVersionRequested;
>    WSADATA wsaData;
>    int err;
> 
>    wVersionRequested = MAKEWORD( 2, 2 );
> 
>    err = WSAStartup( wVersionRequested, &wsaData );
>    if( err != 0 ) {
>        printf( "Unable to load ws2_32.dll: error %u\n", err);
>      	exit(1);
>    }
>    if( ( sv = getservbyname("ftp", "tcp") ) )
>        printf( "getservbyname() returned port %hu\n",
>            ntohs(sv->s_port));    
>    else
>        printf( "getservbyname() returned NULL: win32 error %u\n",
>            WSAGetLastError());
>}
>ENDL
>
>  
>
This one didn't link properly.  Anyway, here's the output:

/cygdrive/c/DOCUME~1/Carlo/LOCALS~1/Temp/ccYVHUNc.o(.text+0x3f):getservbyname-mingw.c: 
undefined reference to `_WSAStartup AT 8'
/cygdrive/c/DOCUME~1/Carlo/LOCALS~1/Temp/ccYVHUNc.o(.text+0x87):getservbyname-mingw.c: 
undefined reference to `_getservbyname AT 8'
/cygdrive/c/DOCUME~1/Carlo/LOCALS~1/Temp/ccYVHUNc.o(.text+0xa2):getservbyname-mingw.c: 
undefined reference to `_ntohs AT 4'
/cygdrive/c/DOCUME~1/Carlo/LOCALS~1/Temp/ccYVHUNc.o(.text+0xbf):getservbyname-mingw.c: 
undefined reference to `_WSAGetLastError AT 0'
collect2: ld returned 1 exit status

>Both of those should say "getservbyname() returned port 21".  If either
>fails, paste the output.  I suppose it's remotely possible that
>something's wrong with wsock32.dll or ws2_32.dll on your system, but if
>that was the case you'd have many more problems I'd think.
>
>  
>
Hmmm.  There's something fishy of my system....

Thanks a lot!

Best Regards,

Carlo

--
Carlo Florendo
Astra Philippines Inc.
www.astra.ph



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