NetTalk Central

Author Topic: How to get IP address  (Read 22001 times)

Mike Grigsby

  • Sr. Member
  • ****
  • Posts: 380
    • Yahoo Instant Messenger - onthedotsoftware
    • View Profile
    • MyHomeAssets! Software (among others)
How to get IP address
« on: August 01, 2007, 07:58:05 AM »
I'm just stumped on this for some reason: How do I get a) the IP address of the computer the program is running on, and b) the IP address that it appears to be to the outside world (like the router's IP)? Basically I just need to load it into a message string, and can take the rest of the program from there. I can't quite get it. Thanks in advance! MikeG
Mike Grigsby
Credify Systems
Central Oregon, USA

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to get IP address
« Reply #1 on: August 06, 2007, 11:52:03 PM »
Hi Mike,

First assumption to get rid of is that the machine has "an" IP address. It certainly has more than 1, and may actually have quite a few.

Second assumption to get rid of is that the IP address is unique. It's not.

Lastly, the address an "outsider" uses is almost certainly not the IP Address of this machine - it's the IP address of the router.

So that all said, what are you really trying to know?

The only really useful number is the IP address others will use to contact you. And that's the only one you can't determine just on that machine. In order to determine your IP address, you need to "bounce" a packet off another machine, and get it to tell you what your IP is.

There are a few ways to do this, one of the easiest is to use the NetWebClient to do a fetch on
http://whatismyip.com/
and the page that comes back contains the IP address.

Cheers
Bruce