Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
EnTerr
Roku Guru

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 4
RokuJoel
Binge Watcher

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
Roku Guru

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
Channel Surfer

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
Roku Guru

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 :oops:
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
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.