Open System Services Library Calls Reference Manual (G06.28+, H06.05+)

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
H-series OSS processes: /G/system/zdllnnn/zinetdll
SYNOPSIS
#include <netdb.h>
struct servent *getservbyport (
int port,
const char *proto);
PARAMETERS
port Species the port number for the service, in network-byte order.
proto Species the protocol name to use when contacting the service.
DESCRIPTION
The getservbyport() function searches the /etc/services le 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 le 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 le
denes 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 le occupies
a single line and has four elds: the ofcial service name, the port number, the
protocol name, and aliases.
RELATED INFORMATION
Functions: getservbyname(3), getservent(3), setservent(3), endservent(3).
Files: services(4).
374 Hewlett-Packard Company 527187-007