Original Post
🔒 Locked
IP number
Advertisement
You probably can, but I wouldn't do it depending on why you need the ip address. Due to NATs the address you get may not be publically addressable and you may need to use some form of NAT punch through to overcome this. To get your external IP you will need to bounce a query off an external server.
1 more wrinkle ... a computer may have more than 1 IP address. Many current motherboards have dual NICs built-in, and of course many more people use wireless. Which also means the IP can change at any time. Much like USB hotplugging, there are API calls to be notified of such changes though.
Ignoring all that though ...
very usefull information for Win32 API winsock programming can be found here:
http://tangentsoft.net/wskfaq/intermediate.html
primarily at section 3.3 "How do I get my IP address from within a Winsock program?"
you will see of course the sample program involves a loop ... which cannot easily be ignored - but you can safely ignore the adding, removing, changing of the information while your running ... for now at least.
Ignoring all that though ...
very usefull information for Win32 API winsock programming can be found here:
http://tangentsoft.net/wskfaq/intermediate.html
primarily at section 3.3 "How do I get my IP address from within a Winsock program?"
you will see of course the sample program involves a loop ... which cannot easily be ignored - but you can safely ignore the adding, removing, changing of the information while your running ... for now at least.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement