Function getservbyport
Get service information from a port number and a protocol name.
struct servent {
const char * s_name; // official name of the service
const char * * s_aliases; // alternative names (will be NULL)
int s_port; // port number in network byte order
const char * s_proto; // name of the protocol
};
struct servent * getservbyport(int port, char * proto);
ParametersportPort number of service to query (e.g. 80 for www or 21 for ftp, etc).
protoPointer to protocol name (e.g. "tcp", "udp").
return valueReturns a pointer to a servent structure if successful, otherwise NULL. If an error occurred, call xn_getlasterror and xn_geterror_string to return the error value. Section Error Codes further describes each error. Possible values for this function are:
Value |
Meaning |
ENODATA |
The DNS server could not resolve the protocol name. |
ENOTINITIALIZED |
RTIP-32 has not been initialized (xn_rtip_init has not been called). |
Socket API
Function getservbyname
Function getsockname
|