- Code: Select all Expand view RUN
- Function PublicIP()
Local cBuffer, cRequest, cResponse, nBytes, pSocket
INetInit()
pSocket := INetConnect( "checkip.dyndns.org", 80 )
IF INetErrorCode( pSocket ) <> 0
? "Socket error:", INetErrorDesc( pSocket )
INetCleanUp()
QUIT
ENDIF
nBytes := INetSend( pSocket, "GET / HTTP/1.1" + CRLF + "Host: checkip.dyndns.org" + CRLF + "User-Agent: HTTP-Test-Program" + CRLF + CRLF )
cBuffer := Space(512)
cResponse:= ""
WHILE ( nBytes > 0 )
nBytes := INetRecv( pSocket, @cBuffer )
cResponse += Left( cBuffer, nBytes )
cBuffer := Space(512)
ENDDO
INetClose( pSocket )
INetCleanUp()
Return( allTrim( substr( substr( cResponse, rat( "<body>", cResponse ) + 26 ), 1, At( "<", substr( cResponse, rat( "<body>", cResponse ) + 26 ) ) - 1 ) ) )