Gets protocol entry from the /etc/protocols file.
Standard C Library (libc.a)
#include <netdb.h>
int getprotoent_r(protoent, proto_data)
struct protoent *protoent;
struct protoent_data *proto_data;
The getprotoent_r subroutine retrieves protocol information from the /etc/protocols file. An application program can use the getprotoent_r subroutine to access a protocol name, its aliases, and protocol number. The getprotoent_r subroutine opens and performs a sequential read of the /etc/protocols file. This subroutine writes to the protoent structure, which contains the fields for a line of information in the /etc/protocols file.
The netdb.h file defines the protoent structure.
Use the endprotoent_r subroutine to close the /etc/protocols file. Static data is overwritten in subsequent calls when using the getprotoent subroutine. The getprotoent_r subroutine does not overwrite.
Item | Description |
---|---|
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.
Item | Description |
---|---|
/etc/protocols | Contains protocol information. |