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<>“0.0.0.0” then
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 myIP.dk my IP address is reported as a totally different number - currently 18.104.22.168 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 whatismyip.com 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(“ifconfig.me/ip”, 10)
Dim My_HTTPSocket As New HTTPSocket
My_HTTPSocket.Yield = True
MsgBox My_HTTPSocket.Get("http://myip.dnsomatic.com", 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.