GETPROTOENT(3n,L) AIX Technical Reference GETPROTOENT(3n,L) ------------------------------------------------------------------------------- getprotoent, getprotobynumber, getprotobyname, setprotoent, endprotoent PURPOSE Gets protocol entry. LIBRARY Internet Library (libc.a) SYNTAX #include struct protoent *getprotoent ( ) void setprotoent (stayopen) int stayopen; struct protoent *getprotobyname (name) char *name; void endprotoent ( ) struct protoent *getprotobynumber (proto) int proto; DESCRIPTION The getprotoent, getprotobyname, and getprotobynumber subroutines each return a pointer to an object. This object is a protoent structure, which contains the field of a line in the /etc/protocols file (the network protocol data base). The protoent structure is defined in the netdb.h header file, and it contains the following members: char *p_name; /* official name of protocol */ char **p_aliases; /* alias list */ long p_proto; /* protocol number */ The members of the structure are defined below: p_name Official name of the protocol. p_aliases An array, terminated by a 0, of alternate names for the protocol. p_proto The protocol number. The getprotoent subroutine reads the next line of the file. If the file is not open, getprotoent opens it. Processed July 12, 1991 GETPROTOENT(3n,L) 1 GETPROTOENT(3n,L) AIX Technical Reference GETPROTOENT(3n,L) The setprotoent subroutine opens and rewinds the file. If the stayopen parameter is 0, the protocol data base is closed after each call to getprotobyname or getprotobynumber. Otherwise, the file is not closed after each call. The endprotoent subroutine closes the file. The getprotobyname and getprotobynumber subroutines search the file sequentially from its beginning until finding a matching protocol name or protocol number, or until encountering the end of the file. RETURN VALUE A pointer to a protoent structure is returned on success. Note: The return value points to static data that is overwritten by subsequent calls. A NULL pointer (0) is returned if an error occurs or the end of the file is reached. FILE /etc/protocols Protocol name data base. RELATED INFORMATION The discussion of /etc/protocols in AIX TCP/IP User's Guide. Processed July 12, 1991 GETPROTOENT(3n,L) 2