一、getservbyname函数原型
#include <netdb.h> struct servent *getservbyname(const char *servname, const char *protoname); 返回:成功为非空指针,否则为NULL且设置h_errno
二、servent结构
struct servent { char *s_name; char **s_aliases; int s_port; char *s_proto; };
三、getservbyport函数原型
#include <netdb.h> struct servent *getservbyport(int port, const char *protoname); 返回:成功为非空指针,否则为NULL且设置h_errno 注意:port参数的值必须为网络字节序