int hostshort) unsigned long int ntohl(unsigned long int netlong) unsigned short int ntohs(unsigned short int netshort)
在这四个转换函数中,h 代表host, n 代表 network.s 代表short l 代表long 第一个函数的意义是将本机器上的long数据转化为网络上的long. 其他几个函数的意义也差不多.
3.2 IP和域名的转换 在网络上标志一台机器可以用IP或者是用域名.那么我们怎么去进行转换呢?
struct hostent *gethostbyname(const char *hostname) struct hostent *gethostbyaddr(const char *addr,int len,int type) 在中有struct hostent的定义 struct hostent{ char *h_name; /* 主机的正式名称 */ char *h_aliases; 页码:[1] [2] [3] [4] [5] [6] 第2页、共6页 |