Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
lkrocek
Level 7

TCP Socket client

Hi,

I need help. How I can create TCP socket client connection?

I read https://sdkdocs.roku.com/display/sdkdoc/roStreamSocket there is not much information in detail and if I am right first sample is a client so I should mix usage of both samples, so I tried it but from some reasons it takes really long time (at least 30 seconds) to receive first message from port, does anyone know where could be a problem?

Details:

  • I have Roku 3 with firmware version 8

  • I use sample app 

  • I created and putted my own ComponentLibrary

  • Created a Task component to make network connection working

  • I code below putted into my task component:
    port = CreateObject("roMessagePort")
    connection = {}

    sendAddress = CreateObject("roSocketAddress")
    sendAddress.SetAddress("echo.websocket.org:80")' WebSocket test server -> http://www.websocket.org/echo.html '

    sock = CreateObject("roStreamSocket")
    sock.setMessagePort(port)

    sock.SetSendToAddress(sendAddress)

    sock.notifyReadable(true)
    sock.Listen(3)

    If not sock.eOK() then
      print "socket error"
      stop
    End If

    If sock.Connect()
      Print "Connected Successfully"
    Else
      Print "Connection failed"
    End If

    while True
      ssevent = port.WaitMessage(0)

      if type(ssevent) = "roSocketEvent"
         print "connection established from port"
      end if
    end while

Platforms integration specialist
====================
@ https://suite.st/
0 Kudos
4 Replies
acreskey
Level 7

Re: TCP Socket client

It looks like you are trying to connect the tcp socket to a websocket server, which is a problem.
0 Kudos
lkrocek
Level 7

Re: TCP Socket client

found lib which is handling websocket, solved
Platforms integration specialist
====================
@ https://suite.st/
0 Kudos
acreskey
Level 7

Re: TCP Socket client

Thanks for sharing that.

Because this library doesn't support secure sockets (because roStreamSocket doesn't), a fully-implemented Roku WebSocket addition would still be useful.
0 Kudos
lkrocek
Level 7

Re: TCP Socket client

Currently this library is working really nice on dev branch, but it has one uncomfortable issue which is a performance on slower devices, would be nice if someone help to solve it!

https://github.com/rolandoislas/BrightW ... -411021770
Platforms integration specialist
====================
@ https://suite.st/
0 Kudos