Your Digital Media Has Never Looked So Good

 
pdineshkumar55
Topic Author
Posts: 29
Joined: Thu Jun 25, 2015 12:56 am

Working on roStreamSocket Roku

Wed Oct 07, 2015 9:28 pm

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.
 
sjb64
Posts: 108
Joined: Thu Apr 16, 2015 1:13 pm
Location: Memphis, TN

Re: Working on roStreamSocket Roku

Thu Oct 08, 2015 6:26 am

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()
FlixRaider channel

Who is online

Users browsing this forum: No registered users and 8 guests