Checking IP address with TCPSocket

I have written a small program to check my computer’s internet IP address. The window has a small label called lab and a button and the button code is:

[code] dim t as new TCPSocket

if t.LocalAddress<>“” then
lab.text=“Not Connected”


I wrote it on a Mac and compiled it for Mac and PC. The trouble is that both standalone machines are using the same router but both report different IP addresses - both addresses begin 192.168 but the 3rd and 4th numbers are widely different.

Worse than that, if I go to a website such as my IP address is reported as a totally different number - currently on both of the machines. Can anyone suggest what the problem is?

I’ve managed to solve my own problem - LocalAddress is the IP address of the computer used by the router to identify different machines logged on. To get the IP address seen by the rest of the world it is necessary to create an HTTPSocket and use Get to draw a response from a website that includes a REMOTE_ADDR = line and use string handling to pull out the IP address. There are one or two conversations elsewhere in this forum about it. I should have done a more thorough search. Thanks.

You want the IP of the router, not the PCs. Each of them will report their local IP. You might try loading a site like with a HTTPSocket and data mining the resulting string. That’s pretty trivial.

Can also be done this way:

[code] Dim sock as New HTTPSocket
Dim result as String

result = sock.Get(“”, 10)
MsgBox result[/code]

Another solution:

Dim My_HTTPSocket As New HTTPSocket My_HTTPSocket.Yield = True MsgBox My_HTTPSocket.Get("", 10)

Thanks for those comments. I think I’ve got it figured out now but it’s great to have help so quickly available from more experienced programmers.