views:

136

answers:

2
+1  Q: 

Silverlight Socket

I am trying to connect a Silverlight client to a socket server and continue to get the following error:

An attempt was made to access a socket in a way forbidden by its access permissions.

I believe I need to specify a clientaccesspolicy.xml through either the socket server or the http://:80/clientaccesspolicy.xml path with the following option set

args.SocketClientAccessPolicyProtocol = SocketClientAccessPolicyProtocol.Http

I am not able to get this running. Any suggestions?

A: 

You can't. There would be little point in restricting the TCP port numbers in browser if there were away for you to circumvent these restrictions.

AnthonyWJones
A: 

Au contraire, sockets are vastly supported in Silverlight. There are certain restrictions particularilly the ones I ran into and overcame. Ports 4502-4534 are the only ports you may connect to and you need to provide the clientaccesspolicy.xml via another socket server on the same machine you are connecting to on port 943.

My solution: Added a dedicated socket server on the server to expose the following clientaccesspolicy.xml when a client connects:

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