Problems with /etc/services & getservbyname() function

Philippe Noel
Tue Aug 10 08:25:00 GMT 1999

Hi all,

I'm currently trying to use the function "getservbyname" and I have problems
with.  I do not find any hints on the mailing-list archive nor in the FAQ,
but I saw the function is supported by Cygwin.

The getservbyname() function returns a servent structure for the line from
/etc/services that matches the service name using protocol proto. I
installed the file /etc/services like it is on my Linux system.

Actually, this functions always returns me a NULL pointer.  Does anybody
uses this function in his source code without having problems?  Is there
anything special about /etc/services?

Here is an example of what I am doing:

---- /etc/services content --------------------------------
socorfs		3379/tcp

---- Source code ------------------------------------------
struct servent *serv = getservbyname( "socorfs", "tcp" );
if( serv == NULL )
   return 0;

And the function getservbyname() always return NULL...

Additionnal informations.  Here is how I mount my Cygwin root directory:
Device           Directory           Type        Flags
D:\Cygwin-root   /                   native      text!=binary

P H I L I P P E   N O E L
Socomar International (1995) inc.

Want to unsubscribe from this list?
Send a message to

More information about the Cygwin mailing list