getservbyport()

NAME

getservbyport(), getservbyname(), getservent(), setservent(), endservent() - get service entry

SYNOPSIS

#include <netdb.h>

struct servent *getservent(void) struct servent *getservbyname (char *name, const char *proto) struct servent *getservbyport (int port, const char *proto) void setservent (int stayopen) void endservent (void)

DESCRIPTION

The getservent(2), getservbyname(2) and getservbyport(2) functions each return a pointer to an object with the following structure containing the information from a network services database.

struct servent {
	char * s_name; /* official name of service */
	char ** s_aliases;  /* alias list */
	int s_port; 	 /* port service resides at */
	char * s_proto;  /* protocol to use
};

The members of this structure are:

s_name
The official name of the service.
s_aliases
A zero terminated list of alternate names for the service.
s_port
The port number at which the service resides. Port numbers are returned in network byte order.
s_proto
The name of the protocol to use when contacting the service.

The getservent(2) function reads the next line of the file, opening the file if necessary.

The setservent(2) and endservent(2) functions are no-ops, provided for portability.

The getservbyname(2) and getservbyport(2) functions return information from a matching protocol name or port number. If a protocol name is also supplied (proto is non-NULL), searches must also match the protocol.

NOTES

These functions use static data storage; if the data is needed for future use, it should be copied before any subsequent calls overwrite it.

RETURN VALUES

Returns NULL pointer on end of file (EOF) or error.

FILES

These functions make use of the following files:

%WINDIR%/system32/drivers/etc/services
The network services database, where %WINDIR% is the Windows installation directory.

SEE ALSO

getprotoent(2)