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: 

Working on roStreamSocket Roku

Hi Everyone,

I need to achieve TCP connection using roStreamSocket. I have to set the roku as the client and I am having the AWS server that acts as the server.

I need the roku socket to listen and get the data from the server. Roku SDK document having not much in detail.

Can anyone please explain, Is it possible?, how can I achieve it.

Thank you,
P.Dineshkumar
I am using Roku 4 - 4400X Model.
0 Kudos
1 REPLY 1
sjb64
Roku Guru

Re: Working on roStreamSocket Roku

Heres a snippet of my code, hope it helps...
Socket = CreateObject ("roStreamSocket")
Port = CreateObject ("roMessagePort")
Buffer = CreateObject("roByteArray")
Buffer[65536]=0
IP = CreateObject("roSocketAddress")
IP.SetPort(####)
IP.SetHoneName("www.????????.com/....")
Socket.setSendToAddress (IP)
Socket.Connect()
if Socket.IsConnected()
Socket.NotifyReadable(true): Socket.NotifyWritable(true): Socket.NotifyException(true): Socket.SetMessagePort (Port)
while true
Event = Port.GetMessage()
StepBackgroundTasks()
if type(Event)="roSocketEvent" and Socket.IsWritable()
Socket.SendStr(...whatever to send...)
exit while
end if
end while
Offset=0
Bytes=-1
while Bytes<>0
Event = Port.GetMessage()
StepBackgroundTasks()
if type(Event)="roSocketEvent" and Socket.IsReadable()
Buffer[Offset+Bytes]=0
Bytes=Socket.Receive(Buffer,Offset,65536)
Offset=Offset+Bytes
end if
end while
Socket.Close()
0 Kudos