The ExternalAddress property returns the IP address
assigned to the router that connects the local host to the
Internet. This is typically used by an application executing on a
system in a local network that uses a router which performs Network
Address Translation (NAT). In that network configuration, the
LocalAddress property will only return the IP address for
the local system on the LAN side of the network unless a connection
has already been established to a remote host. The
ExternalAddress property can be used to determine the IP
address assigned to the router on the Internet side of the
connection and can be particularly useful for servers running on a
system behind a NAT router.
Using this property requires that you have an active connection
to the Internet; checking the value of this property on a system
that uses dial-up networking may cause the operating system to
automatically connect to the Internet service provider. The control
may be unable to determine the external IP address for the local
host for a number of reasons, particularly if the system is behind
a firewall or uses a proxy server that restricts access to external
sites on the Internet. If the external address for the local host
cannot be determined, the property will return an empty string.
If the control is able to obtain a valid external address for
the local host, that address will be cached for sixty minutes.
Because dial-up connections typically have different IP addresses
assigned to them each time the system is connected to the Internet,
it is recommended that this property only be used in conjunction
with broadband connections using a NAT router.
It is important to note that checking this property value may
cause the thread to block until the external IP address can be
resolved and should never be used in conjunction with non-blocking
(asynchronous) socket connections. If you need to check this
property value in an application which uses asynchronous sockets,
it is recommended that you create a new thread and access the
property from within that thread.