5 ms·
Reference: http://tools.ietf.org/html/rfc1123#page-13 http://tools.ietf.org/html/rfc1123#page-13 But note that the RFC assumes there will never be a numeric TL
by qjz 16y ago
Reference: http://tools.ietf.org/html/rfc1123#page-13 http://tools.ietf.org/html/rfc1123#page-13
But note that the RFC assumes there will never be a numeric TLD. Furthermore, it suggests checking the string syntactically to determine if it's in dotted decimal form, remaining somewhat ambiguous about what to do if the hostname looks like IPv4, but the connection fails (it seems unwise to do a DNS lookup for every IPv4 address that's offline). Since IPv4 is relatively easy to validate, it would have made a lot more sense for a numeric TLD to select a number outside the range of 0-255, such as 4200. Then it's obvious that 1.2.3.4200 is a hostname (or harmless typo), and not an IP address.
- andfarm 16y agoA lot of parsers do support numbers outside 0-255, though, and treat them as "packed" addresses. For instance, 127.0.1, 32512.1 and 2130706433 are all sometimes treated as alternate representations of 127.0.0.1.
- metageek 16y agoThere's also RFC-1738 (URL syntax), which says: host The fully qualified domain name of a network host, or its IP address as a set of four decimal digit groups separated by ".". Fully qualified domain names take the form as described in Section 3.5 of RFC 1034 [13] and Section 2.1 of RFC 1123 [5]: a sequence of domain labels separated by ".", each domain label starting and ending with an alphanumerical character and possibly also containing "-" characters. The rightmost domain label will never start with a digit, though, which syntactically distinguishes all domain names from the IP addresses. http://www.ietf.org/rfc/rfc1738.txt http://www.ietf.org/rfc/rfc1738.txt