Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

getprotobyname() - get the number of the protocol

&pagelevel(3)&pagelevel

#include <netdb.h>

Kernighan-Ritchie-C:
struct protoent *getprotobyname(name);

char *name;

ANSI-C:
struct protoent* getprotobyname(char* name);


Description

Use of the getprotobyname() function only makes sense in the AF_INET and AF_INET address families.

The getprotobyname() function returns a pointer to an object with the protoent structure described below. This structure contains the protocol number associated with the protocol name name.

The protoent structure is declared in <netdb.h> as follows:

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

Description of protoent components:

p_name

Name of the protocol

p_aliases

A list of alternative names (aliases) for the protocol, terminated with null.
Aliases are currently not supported.

p_proto

Number of the protocol; result field of getprotobyname().

Return value

Pointer to an object of type struct protoent. The null pointer is returned if an error occurs.

Note

The data returned in the protoent object is supplied in a static area that is overwritten with each new getprotobyname() call. It must therefore be copied if it needs to be saved.