CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    Dec 2008
    Posts
    3

    SocketError.AccessDenied with Silverlight Sockets

    Hi,
    I'm in the middle of trying to get my Silverlight application to communicate via sockets with my webserver but I'm having trouble connecting the Silverlight socket to the server.

    This is the setup:
    My webserver is set to listen to the 5432 port using a TcpListener on IPAddress.Any. I've got a clientaccesspolicy.xml accessable on localhost:943/clientaccesspolicy.xml looking like this:

    Code:
    1    <access-policy>
    2     <cross-domain-access>
    3      <policy>
    4       <allow-from>
    5        <domain uri="*"/>
    6       </allow-from>
    7       <grant-to>
    8        <socket-resource port="4532" protocol="tcp"/>
    9       </grant-to>
    10     </policy>
    11    </cross-domain-access>
    12   </access-policy>
    The webserver hosting the access policy is a homemade one using HttpListeners but that works great using normal WebRequests with silverlight so I cannot see how that would be a problem here.

    I try to setup the silverlight socket using this following code:

    Code:
    1    DnsEndPoint endPoint = new DnsEndPoint("localhost", 4532);
    2    _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
    3    SocketAsyncEventArgs args = new SocketAsyncEventArgs { RemoteEndPoint = endPoint };
    4    args.Completed += OnSocketConnectCompleted;
    5    _socket.ConnectAsync(args);
    Of course I've tried using the 'Application.Current.Host.Source.DnsSafeHost' instead of "localhost" since all tutorials and guides use it but I haven't been able to find any information about what exactly it contains, when I debug my silverapp. it's set to "" (empty string) which of course throws when inserted into the DnsEndPoint.

    Finally worth mentioning is that I've checked the traffic using a sniffer and I cannot even catch the silverlight making any localhost requests so I suspect the problem lies in how I setup the DnsEndPoint (or some such).

    Any help would be superb, I'm really at the end of my rope.



    Edit:
    I just found a post regarding the same matter described here:
    https://silverlight.net/forums/p/21500/75414.aspx

    I did try to change the port to 4530 everywhere, which should be in range, but still no success.
    Last edited by ovidiucucu; December 23rd, 2008 at 08:50 AM. Reason: added [code] and [/code] tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured