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: 
lkrocek
Binge Watcher

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 4
acreskey
Visitor

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
Binge Watcher

Re: TCP Socket client

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

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
Binge Watcher

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
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.