Codesnippets > Network

What's my IP?

(1/1)

Kitty Hello:

--- Code: (glbasic) ---STDOUT "Local IP(s) (for LAN connection): \n" _
+ REPLACE$(NETGETIP$(), "|", "\n")+"\n"

LOCAL myip$, proxy$, port%
// proxy$ = "192.168.168.50"
// port   = 3128

IF port=0 OR LEN(proxy$)=0
// direct connection
myip$=NETWEBGET$("www.whatismyip.com", "/automation/n09230945.asp", 80, 512)
ELSE
// through proxy server
myip$=NETWEBGET$(proxy$, "http://www.whatismyip.com/automation/n09230945.asp", port, 512)
ENDIF

STDOUT "Internet IP:\n"+myip$+"\n"

--- End code ---

FutureCow:
That code snippet appears to be wrong. When specified with a proxy, the last field is the file to write the contents of the webpage to, not the number of bytes to read.

Kitty Hello:
don't mix NETWEBGET and NETWEBGET$ !!!

FutureCow:
I'll test it again tomorrow when I'm at work (ie. behind a proxy) - the documentation is missing in the helpfile for forms of NETWEBGET other than

--- Code: (glbasic) ---contents$ = NETWEBGET$(server$, path$, port%, max_length%)
--- End code ---

Navigation

[0] Message Index

Go to full version