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: 
bojancv
Visitor

Closing Sockets/Stop Tasks on app exit/close

HI everybody,

i am getting starting with Roku development and after playing around with examples and reading through the docs, forums etc i've noticed that there is no app close/exit event handling through app code or handling the Home button etc...

With that in mind i have the following situation:

I start a component Task that opens a TCP socket/connection and listens for some custom commands i send. The Task of course runs in a loop waiting and reading the data as it comes through the socket, updates the app UI and so on...  (similar to this example https://sdkdocs.roku.com/display/sdkdoc/roStreamSocket  just without allowing multiple connections)

How am i supposed to handle closing the TCP socket/port if i am unable to catch the app/exit close events? 

Should i even worry about that on the Roku/BrightScript side, are the sockets automatically closed and Tasks stopped? (i've noticed that the rerunning the app after pressing Home successfully opens the socket connection on the same port so i guess that it got closed properly, but still it kinda feels wrong without any code handling :))

I've seen on this example https://sdkdocs.roku.com/display/sdkdoc/roDataGramSocket  that it says : 
udp.close()  ' would happen automatically as udp goes out of scope

Which leads me to believe that the closing happens automatically when the app closes. (as with some tests i implemented)

Am i getting this right? 🙂  Is so all i need to do is implement some ping/pong events for the client side to be able to detect that the Roku app socket got closed.
0 Kudos
1 REPLY 1
bojancv
Visitor

Re: Closing Sockets/Stop Tasks on app exit/close

Well just to post if anyone bumps into the same question, the sockets are closed automatically and tasks are stopped also.
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.