关于inet_aton和inet_ntoa(perl)
来源:互联网 发布:mac safari httm5 编辑:程序博客网 时间:2024/05/17 00:05
关于inet_aton和inet_ntoa(perl)
得到DNS地址的两个主要函数是Socket模块中的inet_aton()函数,用来保存DNS地址,然后使用inet_ntoa()函数把保存的地址转换成IP地址。
l inet_aton HOSTNAME
Takes a string giving the name of a host, and translates that to an opaque string (if programming in C, struct in_addr). Takes arguments of both the 'rtfm.mit.edu' type and '18.181.0.24'. If the host name cannot be resolved, returns undef. For multi-homed hosts (hosts with more than one address), the first address found is returned.
For portability do not assume that the result of inet_aton() is 32 bits wide, in other words, that it would contain only the IPv4 address in network order.
l inet_ntoa IP_ADDRESS
Takes a string (an opaque string as returned by inet_aton(), or a v-string representing the four octets of the IPv4 address in network order) and translates it into a string of the form 'd.d.d.d' where the 'd's are numbers less than 256 (the normal human-readable four dotted number notation for Internet addresses).
e.g.
use Socket;
my $SiteName;
my $Address;
$SiteName = 'ebs12.hand-china.com';#$SiteName = '192.168.11.13';
$Address = inet_ntoa(inet_aton$SiteName);
print inet_aton($SiteName),"/n";
print "The DNS address of ebs12.hand-china.com is $Address/n";
结果:
括_
The DNS address of ebs12.hand-china.com is 192.168.11.13
我们可以看到print inet_aton($SiteName),"/n";打印出来的是“括_”。所以,我们可以得到inet_aton()函数返回的是“an opaque string”,一个模糊的字符串。
再看print "The DNS address of ebs12.hand-china.com is $Address/n";
打印出来的结果是“The DNS address of ebs12.hand-china.com is 192.168.11.13”。所以,我们可以得出inet_ntoa()函数返回的是IP地址。
- 关于inet_aton和inet_ntoa(perl)
- 关于inet_aton和inet_ntoa(perl)
- 区分inet_addr、inet_aton和inet_ntoa
- IP处理函数inet_aton()和inet_ntoa()
- IP处理函数inet_aton()和inet_ntoa()
- mysql inet_aton和inet_ntoa存储ip地址
- [MySQL]IP处理函数inet_aton()和inet_ntoa()
- IP处理函数inet_aton()和inet_ntoa()使用说明
- 关于Linux的inet_addr inet_aton inet_ntoa 函数 和inet_pton inet_ntop函数
- inet_ntoa、 inet_aton、inet_addr
- Java的inet_aton inet_ntoa
- Linux函数-inet_aton / inet_ntoa
- linux inet_aton inet_ntoa
- inet_ntoa(), inet_aton(), inet_addr
- inet_aton、inet_addr、inet_ntoa函数
- inet_ntoa、 inet_aton、inet_addr
- inet_ntoa、 inet_aton、inet_addr
- inet_ntoa、 inet_aton、inet_addr
- “番茄”让时间变成我们的朋友
- 七年IT经验的七个总结
- Linux内核的链表
- test2
- 网站设计
- 关于inet_aton和inet_ntoa(perl)
- 234
- 基于Cookie的攻击和防范学习总结
- Visual C++中的C运行时库浅析
- Oracle EM 中主机身份证明的问题
- Oracle数据库datetime格式处理摘记
- AIR保存图片到本地
- 2010年第一篇
- SQL Server和Oracle的常用函数比较