Hello,
Welcome to our Microsoft Q&A platform!
From the description of your application scenario, it is necessary to use the server as a data transfer station.
But from your description, the data is transmitted in one direction, that is, the teacher sends a notification to the student, but does not need to receive feedback from the student.
So you can use this process:
The student device establishes a connection with the server and keeps listening -> the teacher sends a request to the server -> the server sends information to all connected devices
After you create a StreamSocket
, if there is no packet transmission for a long time, the connection will be disconnected. If you want to stay connected for a long time, you can set StreamSocketListener.KeepAlive to True
(the default is False
).
In addition, StreamSocket
may be abnormally closed in the following cases:
When the StreamSocket
connection target is out of range
When a file IO error occurs while reading Stream
When the application crashes off
More infomation in this document
In order to ensure the application experience, it is recommended to manually close StreamSocket
, such as at rest.
I believe this design is to ensure the battery life and reduce the resource consumption, so you don't have to worry about creating a StreamSocket
that will affect the battery life of the device.
Thanks!