0

Accepting TCP connections

Hi all,

I'm trying to write a script so that I can connect, via TCP, to a Brightsign. I've got a working script, but when the remote disconnects, this is flagged up in Brightscript as a roStreamEvent. However, the Brightsign does not release the socket, and I can't find a way to do it apart from re-creating the object.

So, we have:

REM TCP Stream - to accept connections and receive data
TCPStream=CreateObject("roTCPStream")
TCPStream.SetReceiveEol(eol)
TCPStream.SetSendEol(eol)
TCPStream.SetLineEventPort(mp)

REM TCP Server - to send data
TCPServer=CreateObject("roTCPServer")
TCPServer.BindToPort(myPort)
TCPServer.SetPort(mp)

And in the listen loop:

REM Disconnected
if type(msg)="roStreamEndEvent"then
print"Remote has disconnected"
TCPStream=Invalid
TCPStream=CreateObject("roTCPStream")
TCPStream.SetReceiveEol(eol)
TCPStream.SetLineEventPort(mp)
endif

Surely there must be a better way of doing this?

1 comment

  • 0
    Avatar
    Bright Scripters

    Whatever works... :)

    Thanks for sharing your code with the community!

Please sign in to leave a comment.