how to get the ip address of my own machine?

I am writing a program and I need to get the ip address of my own machine, how do I do it? preferable for it to be IPv6
Last edited on
An IP address doesn't identify a machine, it identifies a network interface on a machine.
ok so how do I get the ip of the network interface I'm using on my machine?
Which one? You probably have localhost, firewire, wifi, and atleast one ethernet.

There's is no surefire way as it's not always clear, to the the software on your machine, which is the correct route out of your system.

One solution is to connect to a server and have it tell you what the client address was. Of course, if you're behind a NAT you'll get the NAT address.
http://ip1.dynupdate.no-ip.com/
Check your OS' documentation, there's probably a special header file that is OS specific and also has the function for getting the IP address of one of the interfaces.

http://stackoverflow.com/questions/212528/linux-c-get-the-ip-address-of-local-computer

-Albatross
Which one? You probably have localhost, firewire, wifi, and atleast one ethernet.

Sorry for being away for so long, I need the ip of the NIC that my program is currently using
Topic archived. No new replies allowed.