Mail Archives: cygwin/2004/10/13/02:50:49
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 -