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

System Functions (f - i) getservbyport_r(2)
NAME
getservbyport_r - Gets a network service entry by port number (reentrant)
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
[#include <netdb.h>]
#include <spthread.h>
struct servent *getservbyport_r (
int port,
const char *proto,
struct servent *ret,
char *buffer,
int buen
);
PARAMETERS
port Species the port number for the service, in network-byte order.
proto Species the protocol name to use when contacting the service.
ret Points to a servent structure allocated by the caller.
buffer Points to the buffer supplied by the caller and used as a storage space for
returned data.
buflen Species the size of the buffer passed in bytes.
DESCRIPTION
The getservbyport_r() function is the reentrant version of the getservbyport() function.
The getservbyport_r() 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.
This 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.
The getservbyport_r() function updates the servent structure pointed to by the ret parameter.
Storage referenced by the servent structure is allocated from the memory provided using the
buffer parameter, which is buen characters in size.
RETURN VALUES
Upon successful completion, the getservbyport_r() 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
getservbyport_r() fails, a null pointer is returned.
ERRORS
If this condition occurs, the getservbyport_r() function sets errno to the corresponding value:
[ERANGE] Insufcient storage was supplied via buffer and buen to contain the data to be
referenced by the resulting servent structure.
527186-007 Hewlett-Packard Company 3113