协议处理函数
程序员文章站
2022-07-14 20:33:21
...
协议处理函数:
#include <netdb.h>
struct protoent *getprotobyname (const char *);
struct protoent *getprotobynumber (int);
struct protoent *getprotoent (void);
void sethostent (int);
void endprotoent (void);
protoent结构体:
struct protoent
{
char *p_name; /* official protocol name */
char **p_aliases; /* alias list */
short p_proto; /* protocol # */
};
示例:
struct protoent* pt = NULL;
const char protoname = "icmp";
pt = getprotobyname(protoname);