Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

getservbyport(3) OSS Library Calls Reference Manual
NAME
getservbyport - Gets a network service entry by port number
LIBRARY
G-series native OSS processes: /G/system/sysnn/zinetsrl
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zinetdll |
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/yinetdll |
SYNOPSIS
#include <netdb.h>
struct servent *getservbyport (
int port,
const char *proto);
PARAMETERS
port Specifies the port number for the service, in network-byte order.
proto Specifies the protocol name to use when contacting the service.
DESCRIPTION
The getservbyport( ) function searches the /etc/services file sequentially until a match with the
port parameter and with the proto parameter is found. If the proto parameter is a null pointer,
any value in the /etc/services file will match.
The getservbyport( ) function returns a pointer to a structure of type servent whose members
specify data from the /etc/services network services database le. The netdb.h header file
defines the servent structure.
NOTES
The getservbyport( ) return value points to static data, which is overwritten by any subsequent
calls to getservbyport(), getservbyname( ), getservent( ),orsetservent().
RETURN VALUES
Upon successful completion, the getservbyport() function returns a pointer to a servent struc-
ture if the matching entry was found, and a null pointer if no match was found. If the call to get-
servbyport( ) fails, a null pointer is returned.
ERRORS
getservbyport( ) does not set errno.
FILES
/etc/services The Internet network service name database le. Each record in the file occupies
a single line and has four fields: the official service name, the port number, the
protocol name, and aliases.
RELATED INFORMATION
Functions: getservbyname(3), getservent(3), setservent(3), endservent(3).
Files: services(4).
3140 Hewlett-Packard Company 527187-017