Ok, you must have answered correctly to have gotten this address. So now,
you are wondering, how does it really work? Here's the answer.
![]() The simple answer: It's just a number conversion. IP: 70.164.18.44 ![]() Thanks to James Reprogle for finding these beauties!
There IS a notation for binary: 0b. So 0b1101 should work, right? Nope. Most web browsers are written in C, and C does NOT support that
notation. So browser believes that if it doesn't start with a zero, it is a decimal number. Hexadecimal numbers start with 0x, and octal
numbers start with 0. So your browser thinks that the IP you are giving it is either in decimal (1 blah blah blah) or octal (0 blah blah
blah). Unless you use a PERL based browser; then it should understand the 0b0101 notation. If you have access to a unix machine, do a man on inet_addr() [man inet_addr]. This function takes an address from the dotted decimal and converts it to the decimal notation!!! From the man pages:
I tested this using the below C program -- it takes the dotted notation and converts it to decimal. If it is decimal already, it just returns that decimal. NOTE: Compile with this line: gcc -o test test.c -lxnet Usage: Run this program with any number as the first argument.#include <stdio.h> main(int argc, char **argv) { if (argc <= 1) { printf("usage: %s [ octal | hex | IPaddr ]\n",argv[0]) && exit(1); } printf("%u\n", inet_addr(argv[1])); } Then there is a function called inet_ntoa() that translates the decimal back to the IP dotted notation! From the man pages:
And I took a look at code from telnet (the ever standard program), and what do you know! (hostp is the command line variable for the host):
Here is the first line we see after telnet has processed our command line host:/* * For setup phase treat the relay host as the target host. */ real_host = hostp; /*** hostp = xxx.xxx.xxx.xxx ***/ hostp = itelnet_host; temp = inet_addr(hostp); /*** temp is now a decimal *** equivalent of IP addr! ***/ /* If temp is an IP address */ if (temp != (unsigned long) -1) { sin.sin_addr.s_addr = temp; sin.sin_family = AF_INET; (void) strcpy(_hostname, hostp); hostname = _hostname; } else { /* If temp is equal to 4294967295 (an unsigned long representation of -1, which is what you get if you pass inet_addr() letters, such as a hostname), do a DNS lookup using gethostbyname() */ For you C geeks, here is what the sin_addr structure looks like:printf("Trying %s...\n", inet_ntoa(sin.sin_addr)); So, now you know why the URL http://3508506659/~beckman/ip/ works!!! Go tell all your friends. But don't tell them the secret entry door! I will have to KILL you!struct in_addr { union { struct { uchar_t s_b1, s_b2, s_b3, s_b4; } _S_un_b; struct { ushort_t s_w1, s_w2; } _S_un_w; in_addr_t _S_addr; } _S_un; #define s_addr _S_un._S_addr /* should be used for all code */ #define s_host _S_un._S_un_b.s_b2 /* OBSOLETE: host on imp */ #define s_net _S_un._S_un_b.s_b1 /* OBSOLETE: network */ #define s_imp _S_un._S_un_w.s_w2 /* OBSOLETE: imp */ #define s_impno _S_un._S_un_b.s_b4 /* OBSOLETE: imp # */ #define s_lh _S_un._S_un_b.s_b3 /* OBSOLETE: logical host */ }; Thanks for watching! I'll try and find more cool stuff to show you as the days go on. Suggestions? Mail me! -Peter
IPv6 From RFC 2133...Thanks to Elmer Kuehn for pointing out this RFC.
6.5. Address Conversion Functions The two functions inet_addr() and inet_ntoa() convert an IPv4 address between binary and text form. IPv6 applications need similar functions. The following two functions convert both IPv6 and IPv4 addresses: #include |