Android Learning Note (10) URL domain name resolves to IP

Source: Internet
Author: User

In the process of work, I encountered a mobile phone problem detection project, one of the requirements of the function is to obtain the URL of the domain name after the resolution of the IP address, from the Internet to find a large amount of information, are the same use inetaddress through the URL to get DNS resolution IP address. In the initial use of the process, it is not possible to find the correct IP, will throw the address can not be resolved by the exception, it is very strange, but other methods can not find, and because the domain name resolution is very important content, access to Web pages will inevitably use this function, it is impossible to not have an interface to provide, Finally want to try to use ping to curve the national salvation, in the process of testing found ping in: Ping www.baidu.com format can be normal ping, but ping/http/ www.baidu.com situation but can not ping, this let me realize that the process of domain name resolution is only need to find its IP address, has its own implementation of the Protocol, and HTTP is the host communication protocol, and the domain name resolution is irrelevant, so only the hostname can be resolved by the domain name to obtain its ip,http anti- It's an extra thing, so the host name that was passed in to the URL of GetHostName () at the time of the call to InetAddress finally gets the correct answer.

Android Learning Note (10) URL domain name resolves to IP

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.