getprotobyname()

The getprotobyname() call returns a pointer to the ETC\PROTOCOL file entry specified by a protocol name.

Syntax

#include <netdb.h>
struct protoent *getprotobyname(name)
char *name;

Parameters

name

Description

This call searches the ETC\PROTOCOL file for the specified protocol name.

The getprotobyname() call retrieves protocol information from the ETC\PROTOCOL file using the name parameter as a search key. An application program can use this call to access a protocol name, its aliases, and protocol number.

The getprotobyname() call searches the file sequentially from the start of the file until it encounters a matching protocol name, or until it reaches the end of the file.

The getprotobyname() call returns a pointer to a protoent structure, which contains fields for a line of information in the ETC\PROTOCOL file. The protoent structure is defined in the <NETDB.H> file.

Use the endprotoent() call to close the ETC\PROTOCOL file.

Return Values

The getprotobyname() call returns a pointer to a protoent structure for the network protocol specified on the call. The return value points to static data that subsequent API calls can modify. A pointer to a protoent structure indicates success. A NULL pointer indicates an error or EOF.

The protoent structure is defined in the <NETDB.H> header file and contains the following elements:

Element

p _ name p _ aliases p _ proto

Related Calls


[Back: getnetent()]
[Next: getprotobynumber()]