IOS obtains network information, including its own IP address and route address.

Source: Internet
Author: User
========================================================== =============================== Original blog, reprinted please declare the source of Electronic coffee (original id blue rock) ========================================================== ================================

Recently, I encountered a problem when obtaining the Route IP address. On the iPhone, we can see the gateway address from the settings, but the IOS official does not provide an interface to obtain the gateway address.

Finally made the demo, has uploaded to GitHub, address: https://github.com/ygweric/IOS-RouteAddress

However, the problem is that only the IP address in the range of 192.168.x.x can be obtained, which is difficult to solve for other network segments. If a friend knows that he wants to leave a message ^_^.

The final output result is:

2012-11-26 13:06:48.102 RouterAddressDemo[451:907] broadcast address--192.168.1.2552012-11-26 13:06:48.108 RouterAddressDemo[451:907] local device ip--192.168.1.2212012-11-26 13:06:48.111 RouterAddressDemo[451:907] netmask--255.255.255.02012-11-26 13:06:48.114 RouterAddressDemo[451:907] interface--en02012-11-26 13:06:48.116 RouterAddressDemo[451:907] local device ip address----192.168.1.221gateway address--192.168.1.12012-11-26 13:06:48.118 RouterAddressDemo[451:907] r--02012-11-26 13:06:48.120 RouterAddressDemo[451:907] --starttime:1353906408,endtime:13539064082012-11-26 13:06:48.122 RouterAddressDemo[451:907]  time cost getting above info is--0s

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.