michielpost.nl

Sockets in Silverlight 2 Beta 2

08-06-2008

Silverlight 2 Beta 2 needs a policy file before you can connect with sockets.

A policy file looks like this:

<?xml version="1.0" encoding ="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from>
        <domain uri="*" />
      </allow-from>
      <grant-to>
        <socket-resource port="4502-4534" protocol="tcp" />
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>


Before silverlight will connect to your socket server, it will first request the policy file on the target site on port 943. So there needs to be a policy server running on port 943.

A good easy example of a policy server and policy file can be found on MSDN:
http://msdn.microsoft.com/en-us/library/cc645032(VS.95).aspx

You can also download my Chat Socket example, there's a policy server included.

Comments


No comments yet.

New Comment

Name
E-mail (not published)
Comment
Enter the code shown: