Gets protocol entry from the /etc/protocols file by protocol name.
Standard C Library (libc.a)
#include <netdb.h>
int getprotobyname_r(Name, protoent, proto_data)
register const char *Name;
struct protoent *protoent;
struct protoent_data *proto_data;
The getprotobyname_r subroutine retrieves protocol information from the /etc/protocols file by protocol name.
An application program can use the getprotobyname_r subroutine to access a protocol name, aliases, and protocol number.
The getprotobyname_r subroutine searches the protocols file sequentially from the start of the file until it finds a matching protocol name or until it reaches the end of the file. The subroutine writes the protoent structure, which contains fields for a line of information in the /etc/protocols file.
The netdb.h file defines the protoent structure.
The getprotobyname subroutine overwrites any static data returned in subsequent calls. The getprotobyname_r subroutine does not.
Use the endprotoent_r subroutine to close the /etc/protocols file.
Item | Description |
---|---|
Name | Specifies the protocol name. |
protoent | Points to the protoent structure. |
proto_data | Points to the proto_data structure. |
The function returns a 0 if successful and a -1 if unsuccessful.