Board index » delphi » Get external (Non-LAN) IP address from TIdTCPServer

Get external (Non-LAN) IP address from TIdTCPServer


2005-04-12 11:50:56 PM
delphi166
If in the OnExecute event handler I do this...
AThread.Connection.Socket.Binding.PeerIP
...I get the LAN (internal) IP address. I'd like to get the external IP
address.
Any suggestions?
Thanks
 
 

Re:Get external (Non-LAN) IP address from TIdTCPServer

"Annika K" <XXXX@XXXXX.COM>writes
Quote
If in the OnExecute event handler I do this...
AThread.Connection.Socket.Binding.PeerIP
...I get the LAN (internal) IP address. I'd like to get the external
IP
address.
Any suggestions?
In most cases that is impossible. If your PC uses another LAN host as a
gateway, there is no way to determine the gateway external address.
 

Re:Get external (Non-LAN) IP address from TIdTCPServer

"Annika K" <XXXX@XXXXX.COM>writes
Quote
If in the OnExecute event handler I do this...
AThread.Connection.Socket.Binding.PeerIP
...I get the LAN (internal) IP address.
No, you don't. You get the client's external IP that was used to reach your
server.
Gambit
 

Re:Get external (Non-LAN) IP address from TIdTCPServer

The only way you may be able to get the IP is through some service like
www.whatismyip.com and capturing the response.
Srini.
"Annika K" <XXXX@XXXXX.COM>writes
Quote
If in the OnExecute event handler I do this...
AThread.Connection.Socket.Binding.PeerIP
...I get the LAN (internal) IP address. I'd like to get the external
IP
address.
Any suggestions?

Thanks


 

Re:Get external (Non-LAN) IP address from TIdTCPServer

Pardon me for not being specific enough. The client is on my LAN. So I get the
LAN address of the client. I do not want the LAN IP address. I want the
external IP address.
"Remy Lebeau (TeamB)" <XXXX@XXXXX.COM>writes
Quote

"Annika K" <XXXX@XXXXX.COM>writes
news:425bee65$XXXX@XXXXX.COM...

>If in the OnExecute event handler I do this...
>AThread.Connection.Socket.Binding.PeerIP
>...I get the LAN (internal) IP address.

No, you don't. You get the client's external IP that was used to reach your
server.


Gambit


 

Re:Get external (Non-LAN) IP address from TIdTCPServer

"Annika K" <XXXX@XXXXX.COM>writes
Quote
Pardon me for not being specific enough. The client is
on my LAN. So I get the LAN address of the client.
You get the IP that the client is locally bound to in order to reach your
server.
Quote
I do not want the LAN IP address. I want the external
IP address.
You cannot get the client's external IP from your server, unless the
external IP was used to reach your server to begin with.
Why do you need this? What EXACTLY are you trying to accomplish?
Gambit
 

Re:Get external (Non-LAN) IP address from TIdTCPServer

I had a similar requirement - maybe it is the same...
I have a server app and a client app which I want to connect over the
internet when I am away from home. Unfortunately, I have a dynamic IP
address at home which often changes.
So, I thought about posting a text file containing my current WAN IP
address on my web site so it could be accessed from anywhere.
My client software could then access this file to get the IP address of
the machine at home and connect on to the server software (which also
periodically updates the text file if it changes).
I know you can get software to do this, I just wanted to know if it
could be done with Delphi using the Indy (9) components too.
BC