DCSIMG
Silverlight Client With Sockets - Barebones Sample - David Sackstein's Blog

Silverlight Client With Sockets - Barebones Sample

Dan Wahlin wrote an excellent article on Silverlight Client with Sockets - accompanied by a sample application.

My objective in this post is simply to reduce Dan’s application to the bare minimum so that it is easier to reuse.

You can download my reduced sample here.

Changes

These are the differences between my sample and Dan’s.

  1. There are now only three projects: The Silverlight control, the hosting Web site and the server.
  2. I reduced the Silverlight client to contain a single text box displaying a counter whose value is pushed from the server.
  3. Accordingly I deleted all business objects (Teams, Scores etc) from the client and the server.
  4. Then I merged the PolicySocketServer (which provides the cross-domain policy file) and the CounterSocketServer (which does the real work of pushing new counter values to clients) into one executable. As they both block while listening for connections, I ran them both in separate threads.
  5. I reduced all customized logging to good old Console.Write.
  6. I fixed a bug (I think it was a bug).
    In PolicySocketServer.OnSendComplete there was a call to client.Client.EndSendFile. I replaced it with a call to client.Client.EndSend to correspond with client.Client.BeginSend.

Summary

I recommend you read Dan’s article to get the complete picture. I offer you use of this reduced sample to make it easier to reuse the techniques.

Published Sunday, August 23, 2009 2:30 AM by David Sackstein

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above:
Powered by Community Server (Commercial Edition), by Telligent Systems