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

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