In this article I'm trying to explore how one can develop their own IP to Location like stuff. This article will explore simple TCPIP scoket programming.
There are 5 registerer who keeps records of IP addressess Domain Name. I have developed open source whois project which is capable of query almost all
domain extensions like .in , .uk, .com, .mobi etc. You can download it from here http://satalajwhois.codeplex.com/
You can telnet those registrar on port 43 using command promt like this http://www.revenmerchantservices.com/post/2009/07/27/whois-telnet-port-43.aspx
Below is simple code that will query asia pacific network IP whois.apnic.net . Code is simle and self explainetory
using System.IO; public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click1(object sender, EventArgs e)
TcpClient tcpclient = new TcpClient(); // Create TCPClient object
tcpclient.Connect("whois.apnic.net",43); // open port 43 with asia pasific registrar
NetworkStream stream = tcpclient.GetStream(); // Get refrence to opened Network stream
StreamReader reader = new StreamReader(stream); // Lets assign reader to stream
StreamWriter writer = new StreamWriter(stream); // lets assign writer to stream
writer.WriteLine("184.108.40.206"); // lets write IP address to stream. That we will query asia pacific registrar
// Instead of passing IP address above if you pass domain name like http://www.google.in/
// you will get google info in asia pacific network
string strResponse = string.Empty;
strResponse += reader.ReadLine() + Environment.NewLine;
Response.Write(strResponse); // you can parse this response to get location , country owner address etc.
Once you get the response from those registerar you need to Parce it to get your appropriate fields from it like Location City country owner etc.
if that IP dosen't belongs to that registarar you need to query another registarar like ARIN. you can visit http://www.arin.net/
Note* Some shared host provider would not let you open the port 43.
Above code will work fine with Local host and Dedicated hosting
Use below link to share your ideas and reviews about it