Code archives/Networking/What is my public IP?

This code has been declared by its author to be Public Domain code.

Download source code

What is my public IP? by ZJP
(Posted 18 years ago)
How to get your public IP on the net
Print "My public IP is "+WanIP$()
WaitKey

Function WanIP$()
    www=OpenTCPStream( "www.whatismyip.org",80 )
    If Not www Return "127.0.0.1"
    WriteLine www,"GET / HTTP/1.1"
    WriteLine www,"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
    WriteLine www,"Accept: */*"
    WriteLine www,""
    x$= ReadLine(www)
    x$= ReadLine(www)
    x$= ReadLine(www)
    x$= ReadLine(www)
    ip$= ReadLine(www)
    CloseTCPStream www
    Return ip$
End Function

Comments

None.

Code Archives Forum