Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 May : Re: Delphi 2005 Personal and Indy 10.0.75: Indy don't work!!!
| Subject: | Re: Delphi 2005 Personal and Indy 10.0.75: Indy don't work!!! |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Mon, 5 Jun 2006 18:16:34 |
"Jamie Dale" <j.dale@turboz.net> wrote in message
news:4484d1d9@newsgroups.borland.com...
> > Are you taking multiple network adapters into account?
>
> Yes, the IP is checked via an external website using IdHTTP component.
That is not what I asked you. Just checking an external site is NOT a
guarantee that you will be getting the correct IP on the correct network
adapter. If there are multiple adapters installed, you need to find which
adapter is actually connected to the Internet connection, and then ignore
all of the others. All requests to the external site need to be made to go
through that 1 adapter only to ensure the accuracy of the reported IP.
Since you are not doing that, you are likely getting different responses.
That would explain the IP changing when you don't expect it to.
> I don't bother checking network adapters - way too much trouble...
Trouble or not, you should be doing that. If you don't want to do it
programmably, then provide a popup window for the user to specify which
adapter is the one used for Internet connection, and then remember that
adapter each time your program is restarted.
> Here it is:
> IdHTTP1.Response.ExtraHeaders.Add('Turboz IP Checker; Contact:
dale_jamie@yahoo.com');
Why are you doing that? The Response is cleared when Get() is called. If
you are trying to transmit values to the server, then you have to use the
Request property instead.
> Response := IdHTTP1.Get('http://checkip.dyndns.org');
If there are multiple network adapters installed, you should be setting the
TIdHTTP's BoundIP property before calling Get(), so that the external server
is reached on the correct connection. For example, in my own IP Update
program, I use GetAdaptersInfo() to get all available network adapters and
their current IP addresses. This way, my updated is not effected by dynamic
IPs on my LAN that are assigned by DHCP. I can then look for the adapter
that belongs to my Internet connection, and set the BoundIP accordingly when
calling Get().
> //Response is in HTML format:
If you use a different IP lookup service, such as
http://iplookup.flashfxp.com, then you won't have to parse any HTML at all.
> //If we find the word 'Updated' in the response string
I don't know about the particular DynDNS service that you use, but
DynDNS.org sends a 200 HTTP reply if the IP was updated successfully, so
there is no need to parse the response HTML at all. For that matter,
TIdHTTP.Get() will throw an exception if it does not get a 200 reply, so you
wouldn't even need to parse the response HTML anyway. You already know
which specific IP address you are broadcasting to the service, so you don't
need to validate it in the service's response.
Gambit