getservbyname

Returns information about a service, given its name.

Library:LibC
Standard:BSD
Service:Networking

Syntax

  #include <netdb.h> 
   
  struct servent *getservbyname (
     const char   *name,
     const char   *proto);
  

Parameters

name

(IN) Points to the official name of the service.

proto

(IN) Points to the name of the protocol (such as "TCP" or "icmp") to use when contacting a service. The matching is case insensitive.

Return Values

If successful, returns a pointer to a structure of type servent. Otherwise, returns NULL.

Remarks

The getservbyname function returns a pointer to a servent structure in the services file. The function searches for the service from the beginning of the sys:\etc\services file and continues until it finds a matching entry or reaches end-of-file. If proto is NULL, getservbyname returns the first entry matching the service name.

NOTE:Calling any database routine overwrites the results of the last call to getservbyname.

See Also

getservbyport