易读DhcpInfo.ipAddress? [英] Human readable DhcpInfo.ipAddress?

查看:136
本文介绍了易读DhcpInfo.ipAddress?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何从DhcpInfo.ipAddress得到一个可读的IP联系地址?关于它的棘手的事情是,它是一个整数,显然,你不能在一个整数存储的IP地址。因此,如何为IP地址的连接codeD,它可以存储在一个int?本文档不提供任何帮助,这个问题:<一href="http://developer.android.com/reference/android/net/DhcpInfo.html#ipAddress">http://developer.android.com/reference/android/net/DhcpInfo.html#ipAddress感谢: - )

I am wondering how to get a human readable IP Adress from DhcpInfo.ipAddress? The tricky thing about it is, that it is an integer and obviously you can't store an IP address in an integer. So, how is the IP address encoded, that it can be stored in an int? The documentation doesn't give any help to this problem: http://developer.android.com/reference/android/net/DhcpInfo.html#ipAddress Thanks :-)

推荐答案

你其实可以。

IP地址为int是: AABBCCDD 和人类可读的形式是 AA.BB.CC.DD 但在十进制基数。正如你看到的,你可以把它们用位运算,或通过转换INT为字节数组方便地提取。

IP address as int is: AABBCCDD and in human-readable form it is AA.BB.CC.DD but in decimal base. As you see you can easily extract them using bitwise operations or by converting int to byte array.

请参阅图:

这篇关于易读DhcpInfo.ipAddress?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆