views:

211

answers:

1

I need to implement a persistent socket connection from my in-browser Silverlight 4 app to a device on the network.

I need the following:

  1. Connect to it and keep a persistent connection
  2. Send and Receive data
  3. Get some type of event or notification (or detect it) when the connection drops.

Is this possible with Silverlight 4? If so, can someone point me to some examples? All I am finding are some attempts at it with Silverlight 2.

+2  A: 

This is possible. For details, see Working with Sockets on MSDN.

That being said, you are limited here. You can only use the Asynchronous methods in Socket, and you can only use Tcp connections. Given your requirements, however, this shouldn't be a problem. Any asynchronous TCP communication tutorial for C# (including non-silverlight) should apply here, as it will work in Silverlight 4 as well.

Reed Copsey