GLBasic forum

Codesnippets => Network => Topic started by: Kitty Hello on 2010-Jan-20

Title: What's my IP?
Post by: Kitty Hello on 2010-Jan-20
Code (glbasic) Select

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"

Title: Re: What's my IP?
Post by: FutureCow on 2010-Mar-08
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.
Title: Re: What's my IP?
Post by: Kitty Hello on 2010-Mar-08
don't mix NETWEBGET and NETWEBGET$ !!!
Title: Re: What's my IP?
Post by: FutureCow on 2010-Mar-08
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) Select
contents$ = NETWEBGET$(server$, path$, port%, max_length%)