Send IP address?

ManicCW

Well-known member
Joined
Jul 21, 2005
Messages
428
Location
Mostar
Programming Experience
Beginner
Hi,
I have several computers in diffrent towns. Now I allways need to know their IP addressess (they are dynamic). I dont want to use noIP or some similar product. I was thinking about making .net app that will send IP address of computer to internet (write it in XML file or database). Now how can I do:
  • detect when computer is connected to internet
  • send IP address and write it to XML or database
Tnx
 
I did this once before, I wrote a chat app (which I did not finish and deleted btw) which which showed the LAN Ip address as well as WAN (internet) ip address. I cant remember the code and I definitely can't rewrite it for you, but I do know what it did.

It connected to www.showmyip.com or a similar website and then parsed the results retrieving the WAN ip. So if either someone writes you a code to do that or if you can write one yourself. Your in luck.

Also www.google.com.au will help with writing to XML i'm sure and retrieving your WAN ip will also check for internet connection, if it doesn't work then your most likely not connected.

Hope this helps a tiny bit. Cya.
 
Just about everybody connecting to the internet nowadays is behind a router, which is transparent to the applications using internet. It is then the router that is assigned the ip from the isp. Either you query the router for the information, which usually is not possible, else you need to fetch it from an external resource as kurt69 pointed out. The external site will know the public ip of those who connect to it. Easiest and most accurate results you will get if you set up a webservice to return public ip to connected clients.
Here is an article about it:
http://msdn.microsoft.com/msdnmag/issues/05/12/AdvancedBasics/default.aspx

Since this is very common you should be able to find an existing webservice instead of creating your own. Search Google and tell us if you find one.
 
I found one public webservice (several actually) that will tell you external IP. (article: http://msdn.microsoft.com/msdnmag/issues/05/12/AdvancedBasics/default.aspx)
The link to the webservice is: http://www.mcwtech.com/WebServices/WhatIsMyIP/AddressInfo.asmx

What you do in application is add Reference to System.Web.Services.dll, then add Web reference to the above link. Click Go and it will discover available services, then 'add reference' to that.
All you have to do in code now to get the external IP is:
VB.NET:
Dim ws As New com.mcwtech.www.AddressInfo
Label1.Text = ws.GetAddress
(this is called consuming a webservice)
 
Back
Top