lkrocek
8 years agoBinge 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 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