z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


getservbyport()

z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
SC27-3660-00

The getservbyport() call searches the hlq.ETC.SERVICES data set for the specified port number. Searches for a port number must match the protocol, if a protocol is stated.

The getservbyport() call returns a pointer to a servent structure for the port number specified on the call.

#include <manifest.h>
#include <netdb.h>
struct servent *getservbyport(int port, char *proto)
Parameter
Description
port
Port number
proto
Points to the specified protocol
The servent structure is defined in the NETDB.H header file and contains the following elements:
Element
Description
s_name
The official name of the service
s_aliases
An array, terminated with a NULL pointer, of alternative names for the service
s_port
The port number of the service
s_proto
The protocol required to contact the service

Return values

The return value points to static data that is overwritten by subsequent calls. Points to a servent structure indicates success. A NULL pointer indicates an error or end-of-file. When a NULL pointer or 0 is returned, the value of errno is indeterminate, and therefore, the output from a tcperror() call cannot be validated.

Related calls

endservant(), getservbyname(), getservent(), setservent()

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014