logo       

Re: How you could get your public IP from Squeak: msg#00107

lang.smalltalk.squeak.beginners

Subject: Re: How you could get your public IP from Squeak

On Mon, Jun 25, 2007 at 07:36:28AM -0300, Edgar J. De Cleene wrote:
> My router is NOGA KN-S1060
>
> | stream wanIp |
> stream := HTTPSocket
> httpGet: 'http://192.168.1.1/sys_status.htm'
> args: nil
> user: 'admin'
> passwd: 'admin'.
> stream upToAll: 'wanIP'.
> wanIp := stream upTo: $;.
> ^ wanIp := (wanIp findTokens: '"') at: 2
>
> And I have a Mac , a Windows PC and a Linux box on my small LAN
>
> Perhaps this could be useful to some

Here is a variation that uses the public service dyndns:

getPublicIP
| stream |
stream := HTTPSocket httpGet: 'http://checkip.dyndns.com'.
stream upToAll: 'IP Address: '.
^ stream upTo: $<

That page is tiny, and so is pretty quick to download and parse.

--
Matthew Fulmer -- http://mtfulmer.wordpress.com/
Help improve Squeak Documentation: http://wiki.squeak.org/squeak/808


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise