How can I find the IP address of the localhost?

How can I find the IP address of the localhost?

Date Entered: 09/04/1997    Last Updated: 10/16/1998

The Localhost property shows the Windows Network name of the host if the control is not connected and the IP address of the interface through which the connection was made otherwise.

To get the address without connecting simply assign the LocalHost value to the RemoteHost and read the new value of RemoteHost (WinsockLoaded must be true for this operation).

If you want to find the dynamically assigned address when connecting to your Internet Service Provider (ISP) you should use the IPInfo control and check its OtherAddresses property as shown below: (the code is in Visual Basic)

     IPInfo1.HostName = IPInfo1.LocalHost   'resolve the LocalHost name
     DoEvents    'let the message be dispatched

     'show the static as well as dynamic addresses
     Debug.Print IPInfo1.HostAddress & " " & IPInfo1.OtherAddresses 


We appreciate your feedback.  If you have any questions, comments, or suggestions about this entry please contact our support team at kb@nsoftware.com.