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: 
greubel
Visitor

Question about joinGroup()

What is the correct call to "Boolean joinGroup(Object ipAddress)" ?
Object ipAddress is not defined in BRS.
Unable to locate what an object of "ipAddress" is. Have tried various different values BUT always returns FALSE.
0 Kudos
16 REPLIES 16
kbenson
Visitor

Re: Question about joinGroup()

Have you tried roSocketAddress? That seems like it might be what they are looking for (especially since other methods expect that).

My guess is that roSocketAddress is something like an in_addr c struct under the covers, and the other wrapped libraries expect that structure.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
greubel
Visitor

Re: Question about joinGroup()

Gave that a try but it also fails.
Would it fail if another process had already performed a joinGroup on the same port ?
0 Kudos
eswarbala
Visitor

Re: Question about joinGroup()

greubel - Did you have any luck getting joingroup to be successful? It always returns failure for me.

Roku SDK ships with socketoptions.brs (in socket_tests) that appear to run some tests on socket . This has tests for joingroup/dropgroup and that fails as well.
0 Kudos
greubel
Visitor

Re: Question about joinGroup()

No, also have a problem with inconsistent connects. Some times they work and other times not at all.
0 Kudos
eswarbala
Visitor

Re: Question about joinGroup()

Do you mean sometimes joingroup works? If so do you mind sharing how?

As per the SDK sample in socketoptions.brs
*create roSocketAddress
*call roSocketAddress.setHostName and set the group IP address
* call joingroup with this roSocketAddress.

I have tried several variations of this with no success. For ex: In posix api

* create udp socket and bind (in Roku's SDK call setAddress on Socket) to local interface (socketoptions sample doesn't do this)
* set reuse if needed.
* setsockopt with ip_mreq struct for joining multicast group (In Roku's case new socketaddress with hostname set to multicast group and call joingroup)
* Expect IGMP packet sent out <- Doesn't happen

These steps fail too.
0 Kudos
eswarbala
Visitor

Re: Question about joinGroup()

Can a Roku engineer please chime-in in this discussion?

If the multicast joingroup is supposed to work fine, can I please request a few lines of code snippet demonstrating *how to use it correctly*?

Using it as per the sdk sample or like you would do in posix, seems unsuccessful.

thanks
0 Kudos
greubel
Visitor

Re: Question about joinGroup()

I agree !
There are a lot of things about the SDK socket() methods that do not function at all !
Been beating my head against the wall for over a month now.
0 Kudos
RokuJoel
Binge Watcher

Re: Question about joinGroup()

Hi folks. Please email me a detailed a description of each issue you are having with the Socket API, along with an example project or a code snippet that demonstrates the problem.

email to jbraverman @ roku . com (no spaces of course)

I'll be filing one or more bugs based on your responses, please put [socket api] in the subject of the message so I can filter them.

- Joel
0 Kudos
RokuMEmerson
Visitor

Re: Question about joinGroup()

Here is complete, runnable code for a 5-minute listener on the SSDP multicast group:

function Main()
facade = CreateObject("roScreen")

search = Listen_SSDP()
timeout = 5 * 60 * 1000
numResponses= Wait_SSDP(search, timeout)

print "SSDP Listen got"; numResponses; " responses"
end function

function Listen_SSDP() as Object
port = CreateObject("roMessagePort")

ssdpAddress = "239.255.255.250"
ssdpPort = 1900

groupAddr = CreateObject("roSocketAddress")
groupAddr.setAddress(ssdpAddress)
groupAddr.setPort(ssdpPort)

listenAddr = CreateObject("roSocketAddress")
listenAddr.setPort(ssdpPort)
listenAddr.setAddress("0.0.0.0")

listen = CreateObject("roDatagramSocket")
listen.setReuseAddr(true)
listen.setAddress(listenAddr)
listen.joinGroup(groupAddr)
listen.setMessagePort(port)
listen.notifyReadable(true)

print "SSDP Listen"
print

return listen
end function

function Wait_SSDP(socket as Object, timeout as Integer) as Integer
numResponses = 0

elapsed = CreateObject("roTimespan")
remaining = timeout - elapsed.totalMilliseconds()

while remaining > 0
msg = wait(remaining, socket.getMessagePort())
if type(msg)="roSocketEvent"
if socket.isReadable()
results = socket.receiveStr(255)
print "SSDP Listen gets from "; socket.getReceivedFromAddress().getAddress(); ":"
print results
numResponses = numResponses + 1
end if
else
exit while
end if
remaining = timeout - elapsed.totalMilliseconds()
end while
return numResponses
end function
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.