Hi everybody,
is it possible to find ip with C code.
i am not looking for ip, which we find with ipconfig.
i want to find ip, which is written on web site "whatismyip.com" or "myip.com" ....
thanks
Hi everybody,
is it possible to find ip with C code.
i am not looking for ip, which we find with ipconfig.
i want to find ip, which is written on web site "whatismyip.com" or "myip.com" ....
thanks
It seems you want the public IP address. This may be difficult to get without contacting an external server. For a simple method, how about the following:
1. contact the server "whatismyipaddress.com"
2. request the http page /
3. parse the downloaded page to find your ip address
For more info and an alternative (STUN server) see this thread: networking - Obtaining Own External IP Address in POSIX C - Stack Overflow
I wonder if it is possible to to via the proxy serve back to your own computer and get the address that way somehow?
Just a thought really.
Bit beyond me to do I think, but I guess you could have one program on you PC connecting to another receiving program via the proxy.
Also there are two types of proxy I think one where you put in a proxy address in on your PC connection instructions and another
where you don't use a proxy address on your PC but connect to a proxy via HTML, II think these are called HTML proxies?
Or perhaps should be lol.
Not to sure what I am talking about but there are two ways, one where you type in an IP number and another were you connect to a
site and type in the web address you want and it's all html (or whatever).
Generally a PC does not know it's real external address (the one it gets told is external is likely modified silently by a NAT router like an ADSL router or similar before touching the Internet, and the ISP may even then - on top of that - change your external address at any time). Thus a computer cannot reliably detect its own external IP address without contacting an external server and that server saying "Okay, I see a connection from x.x.x.x, and that's got the magic number I gave you in it, so that must be you and therefore your external address".
This means that you need an external server, with Internet connection, running a program 24/7 to reliably detect your external IP address. That's what those websites are, basically (and the "magic number" is a cookie sent with the HTTP request, normally). The "internal" part of the program is just something that talks to an external server and gets an answer back ("your IP is x.x.x.x"), no matter how that's done.
How do those external sites find your IP? They literally just look it up in their connections list or in the Apache logs of their server (all your communications will appear to come from x.x.x.x, for example, and be logged as such). How do you discover your own external IP? You ask an external server that is running a program that accepts connections all the time. There's no way to do it just "in C" (i.e. locally on your own machine) without that external server. And the way to do it is to talk to an external server and parse the result it gives which, hopefully, will include your correct external IP (so there's no difference between, say, using libcurl to get a URL from whatismyip.com, or doing it all yourself by renting an external server all the time).
The biggest question is really: Why do you need the external IP? Surely anything that needs to know the external IP could just accept connections from the Internet at a known, fixed address and work "forwards" instead of "backwards" (and likely anything that has an external IP won't accept incoming connections by default, so it wouldn't be useful to KNOW the external IP of your own machine anyway - as telling it to anyone is going to need you to play with your router settings and port-forwarding to do anything practical!).
- Compiler warnings are like "Bridge Out Ahead" warnings. DON'T just ignore them.
- A compiler error is something SO stupid that the compiler genuinely can't carry on with its job. A compiler warning is the compiler saying "Well, that's bloody stupid but if you WANT to ignore me..." and carrying on.
- The best debugging tool in the world is a bunch of printf()'s for everything important around the bits you think might be wrong.