getservbyport

Gets information on the specified port from the network services database.

Format

#include  <netdb.h>

struct servent *getservbyport  (int port, char
                               *proto);

Arguments

port
The port number to search for.
proto
A pointer to a string containing the name of the protocol to search for.

Description

This routine searches sequentially from the beginning of the file until a matching port is found, or until an EOF is encountered. If a protocol name is also supplied (non-NULL), searches must also match the protocol.

This routine returns a pointer to a servent structure containing the broken-out fields of the requested line in the network services database. See the <netdb.h> header file for a description of the servent structure.

All information is contained in a static area, so it must be copied if it is to be saved.

See also getservbyname in this section.

Return Values
NULL  Indicates EOF or an error. 
A pointer to a servent structure. 


Previous Page | Next Page | Table of Contents | Index