Silverlight Socket Comments

Michael Schwarz on Monday, March 10, 2008

During my experience with Silverlight 2 beta 1 [1] and the use of sockets I have collected some comments that may help you starting with sockets inside Silverlight:

<li>The current beta version 1 of Silverlight 2 starts a reverse DNS lookup for the host name you connect to (<a href="" target="_blank">more details</a>). This will be changed in future versions.</li> <li>To connect to a server you have to create an instance of <em>DnsEndPoint</em> class which can be done like this: <br></li> <div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:3da2e087-a998-4067-8dcb-eec780d60db5" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><pre style="background-color:White;;overflow: auto;"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

--><span style="color: #000000;">DnsEndPoint endPoint </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> DnsEndPoint( Application.Current.Host.Source.DnsSafeHost, Application.Current.Host.Source.Port);</span></div></pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. --></div>

<li>One additional restriction on Silverlight 2 beta 1 is that the port range that a network application is allowed to connect to must be within the range of 4502-4532. These are the only ports allowed for connection from the current beta except the port number the .XAP file is downloaded from which is by default port 80 for http Web applications.</li>

<li>There is no synchronous connect, send or receive available (I'm very happy about that!).</li>

<li>IPv4 or IPv6 are both available depending if local computer has support enabled for each.</li>

Site of origin connectivity is intended only as an interim solution in the beta 1 until the full cross-domain model can be put in place for Silverlight 2.

I got a question if it is possible to start a socket listener on the client-side Silverlight application. Well, I cannot find any info that this will be able as I don't see any real use of it. Replacing polling is already very easy by opening a socket to a server and waiting for any response (on event). The next days I will publish my chat example using sockets online.