Author Topic: What's my IP?  (Read 4420 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10661
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
What's my IP?
« 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"
 

Offline FutureCow

  • HelpEditor
  • Prof. Inline
  • ******
  • Posts: 680
    • View Profile
Re: What's my IP?
« Reply #1 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.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10661
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: What's my IP?
« Reply #2 on: 2010-Mar-08 »
don't mix NETWEBGET and NETWEBGET$ !!!

Offline FutureCow

  • HelpEditor
  • Prof. Inline
  • ******
  • Posts: 680
    • View Profile
Re: What's my IP?
« Reply #3 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%)