getservbyport()

The getservbyport() call returns a pointer to the ETC\SERVICES file entry specified by a port number.

Syntax

#include <netdb.h>
struct servent *getservbyport(port, proto)
int port;
char *proto;

Parameters

port

proto

Description

This call sequentially searches the ETC\SERVICES file for the specified port number, which must match the protocol if a protocol is stated.

The getservbyport() call retrieves an entry from the ETC\SERVICES file using the port parameter as a search key.

An application program can use this call to access a service, service aliases, the protocol for the service, and a protocol port number for the service.

The getservbyname() call searches the ETC\SERVICES file sequentially from the start of the file until it finds one of the following: