Author Topic: [C#] Ip Address To Ip Number  (Read 2130 times)

0 Members and 1 Guest are viewing this topic.

Offline bubzuru

  • Knight
  • **
  • Posts: 395
  • Cookies: 21
  • everything is contained in the data
    • View Profile
    • New School Tools
[C#] Ip Address To Ip Number
« on: June 28, 2012, 12:23:20 am »
i needed to find out what part of the world an ip addresss came from for my proxy checker  In the most widely installed level of the Internet Protocol (IP) today, an IP address is a 32-bit number that identifies each sender or receiver of information that is sent in packets across the Internet. The IP address is usually expressed as four decimal numbers, each representing eight bits, separated by periods. This is sometimes known as the dot address and, more technically, as dotted quad notation. For example, 127.0.0.1 could be an IP address. The IP Number is the single word (long) notation of an IP Address as it is being used in the database because it is efficient to search between a range of numbers in database.



Code: (c#) [Select]
        public int GenerateIpNumber(string Ip)
        {
            string[] split = Ip.Split('.');
            int ipnum = Convert.ToInt32(split[0]) * (256 * 256 * 256) + Convert.ToInt32(split[1]) * (256 * 256) + Convert.ToInt32(split[2]) * 256 + Convert.ToInt32(split[3]);
            return ipnum;
        }


 
« Last Edit: June 28, 2012, 05:27:02 am by bubzuru »
Damm it feels good to be gangsta
http://bubzuru.comule.com