COHERENT manpages

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

List of available manpages
Index


getprotobyname() -- Sockets Function (libsocket)

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

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

getprotobyname() 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.

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

See Also

endprotoent(),
getprotobynumber(),
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.