How to detect a disconnected connector?
I implemented the task using the async Sockets pattern in Silverlight 3. I started with Michael Schwartz's implementation and was built on top of that, So my Silverlight application establishes a persistent socket connection to the device, and then data is passed as needed between the device and the Silverlight application.
One thing I'm struggling with is how to detect disconnection. I could think of 2 approaches:
-
Keep-Alive. I know it can be done at the Sockets level, but I'm not sure how to do it in an asynchronous model. How would the Socket class let me know that the disconnect has occurred.
-
Manual saving. Basically, I have a Silverlight application sending a dummy packet every 20 seconds or so. If that fails, I would prefer to disable it. However, incredibly, SocketAsyncEventArgs.SocketError always reports success, even if I simply disconnect the device that the Silverlight application is connected to. I'm not sure if this is a bug, or if maybe I need to upgrade to SL4.
Any ideas, guidance or implementation would be appreciated.
a source to share