getservbyname

Gets information on the named service from the network services database.

Format

#include  <netdb.h>

struct servent *getservbyname  (char *name, char
                               *proto);

Arguments

name
A pointer to a string containing the name of the service about which information is required.
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 service name 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 getservbyport 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