COHERENT manpages

This page displays the COHERENT manpage for getprotobynumber() [Get protocol entry by protocol number].

List of available manpages
Index


getprotobynumber() -- Sockets Function (libsocket)

Get protocol entry by protocol number
#include <netdb.h>
struct protoent *getprotobynumber(protocol);
int protocol;

getprotobynumber()  searches file  /etc/protocols, which  holds information
about  all protocols  recognized by  your local  network, for  the protocol
identified by number.  /etc/protocols has to have been opened  by a call to
setprotoent().

getprotobynumber() returns  a pointer to an object  of type protoent, which
is defined in header file netdb.h:

struct protoent {
    char *p_name;   /* official name of protocol */
    char **p_aliases;   /* alias list */
    int p_proto;    /* protocol number */
};

The following details each member:

p_name
     The official name of the protocol.

p_aliases
     This  points to  a  zero-terminated list  of alternate  names for  the
     protocol.

p_proto
     The number of the protocol.

getprotobynumber() returns NULL if an error occurs, or if it encounters the
end of the file.

See Also

endprotoent(),
getprotobyname(),
getprotoent(),
libsocket,
netdb.h,
setprotoent()

Notes

This function uses a static data  space.  If your application needs to save
these data it must copy them before any subsequent calls overwrite them.

At present, only the Internet protocols are understood.