Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
EnTerr
Level 8

Is localhost/127.0.0.1 supported?

Somehow i seem to remember that Roku cannot connect to itself at localhost or even 127.0.0.1 (loopback interface). And the roDeviceInfo.getIPAddrs() seems to hint as if it were the case:
"getIPAddrs()" wrote:
[...] Provides a way for your application to get the local IP address of the Roku box. This can be used in conjunction with the ECP (see the External Control Protocol Guide) command "launch" to start a different channel from the current channel.

But for grins i tried tonight and seems ECP work with both localhost and 127.0.0.1! It's easier that way... am i in the clear to use localhost or am i missing something?
0 Kudos
4 Replies
Roku Employee
Roku Employee

Re: Is localhost/127.0.0.1 supported?

127.0.0.1 should work on newer devices, and localhost as an alias seems to work...sometimes. On legacy 3.1 devices you will need to check to see which interface has a valid ip and then use that address.

- Joel
0 Kudos
EnTerr
Level 8

Re: Is localhost/127.0.0.1 supported?

Oh shucks. It was too good to be true, localhost fails on fw3 indeed. Instead this should do it, i hope?
IP = createObject("roDeviceInfo").getIpAddrs()[0]  'neat: sets IP to invalid if returned array is empty
0 Kudos
TheEndless
Level 7

Re: Is localhost/127.0.0.1 supported?

"EnTerr" wrote:
Oh shucks. It was too good to be true, localhost fails on fw3 indeed. Instead this should do it, i hope?
IP = createObject("roDeviceInfo").getIpAddrs()[0]  'neat: sets IP to invalid if returned array is empty

I don't think that will work. GetIPAddrs returns an associative array, not an array, so there is no index "0". The keys are "eth0" and "eth1". Which is populated depends on if the box is connected wirelessly or not.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
EnTerr
Level 8

Re: Is localhost/127.0.0.1 supported?

"TheEndless" wrote:
I don't think that will work. GetIPAddrs returns an associative array, not an array, so there is no index "0".

Yeah, shame on me for posting before testing Smiley Surprisedops:
Last night i was doing it like so
    ipAA = createObject("roDeviceInfo").getIpAddrs()
for each eth in ipAA:
ip = ipAA[eth]
end for
but on back of my mind was bothering me ip may remain un-initialized and i also like shorter and self-maintaining code, as possible. This morning for some reason i thought i can go shorter. Could it be true that night owls are wiser?

I posted and lunchtime went to the park to get some exercise skating, where it dawned on me numeric indexing won't work. It's amusing, my thinking seems clearer away from the computer during unrelated activities. I rushed on my phone to the forums to delete my mistake... too late. Anyway, ifEnum is what i was thinking, something like (alas, lame) this :
IPs = createObject("roDeviceInfo").getIpAddrs()
IPs.reset()
ip = IPs[IPs.next()]
0 Kudos