Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 861435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:58:42+00:00 2026-05-15T08:58:42+00:00

Trying to call a WCF with a netTcpBinding via Silverlight, I am getting the

  • 0

Trying to call a WCF with a netTcpBinding via Silverlight, I am getting the error:

“TCP error code 10013: An attempt was made to access a socket in a way forbidden by its access permissions.. This could be due to attempting to access a service in a cross-domain way while the service is not configured for cross-domain access. You may need to contact the owner of the service to expose a sockets cross-domain policy over HTTP and host the service in the allowed sockets port range 4502-4534.”

My WCF service is hosted in IIS7, bound to:

http://localhost.myserivce.com on port 80
and net.tcp on port 4502

I can see http://localhost.myserivce.com/myservice.svc if I browse to it (my hosts file is pointing this domain to localhost).
I can also see http://localhost.myserivce.com/clientaccesspolicy.xml:

<?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>

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T08:58:43+00:00Added an answer on May 15, 2026 at 8:58 am

    If you try to establish a TCP connection in port range 4502-4534, Silverlight will first post a request on port 943 to retrieve the client access policy file content – It won’t read the file at http://localhost.myserivce.com/clientaccesspolicy.xml, because this is only for HTTP requests.
    You need to configure your server to listen on TCP port 943, expect a request string equal to <policy-file-request/> and reply with the xml file content.

    The code below shows a basic implementation, you need to pass it a local IPEndPoint using port 943:

    public class SocketPolicyServer
    {
        private const string m_policyRequestString = "<policy-file-request/>";
        private string m_policyResponseString;
        private TcpListener m_listener;
        bool _started = false;
    
        public SocketPolicyServer()
        {
            m_policyResponseString = File.ReadAllText("path/to/clientaccesspolicy.xml");
        }
    
        public void Start(IPEndPoint endpoint)
        {
            m_listener = new TcpListener(endpoint);
            m_listener.Start();
            _started = true;
            m_listener.BeginAcceptTcpClient(HandleClient, null);
        }
    
        public event EventHandler ClientConnected;
        public event EventHandler ClientDisconnected;
    
        private void HandleClient(IAsyncResult res)
        {
            if(_started)
            {
                try
                {
                    TcpClient client = m_listener.EndAcceptTcpClient(res);
                    m_listener.BeginAcceptTcpClient(HandleClient, null);
                    this.ProcessClient(client);
                }
                catch(Exception ex)
                {
                    Trace.TraceError("SocketPolicyServer : {0}", ex.Message);
                }
            }
        }
    
        public void Stop()
        {
            _started = false;
            m_listener.Stop();
        }
    
        public void ProcessClient(TcpClient client)
        {
            try
            {
                if(this.ClientConnected != null)
                    this.ClientConnected(this, EventArgs.Empty);
    
                StreamReader reader = new StreamReader(client.GetStream(), Encoding.UTF8);
                char[] buffer = new char[m_policyRequestString.Length];
                int read = reader.Read(buffer, 0, buffer.Length);
    
                if(read == buffer.Length)
                {
                    string request = new string(buffer);
    
                    if(StringComparer.InvariantCultureIgnoreCase.Compare(request, m_policyRequestString) == 0)
                    {
                        StreamWriter writer = new StreamWriter(client.GetStream());
                        writer.Write(m_policyResponseString);
                        writer.Flush();
                    }
                }
            }
            catch(Exception ex)
            {
                Trace.TraceError("SocketPolicyServer : {0}", ex.Message);
            }
            finally
            {
                client.GetStream().Close();
                client.Close();
                if(this.ClientDisconnected != null)
                    this.ClientDisconnected(this, EventArgs.Empty);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to call a WCF service from my Silverlight 3 app. But... when
I am trying to call my WCF service through a Flex application. I'm getting
I'm trying to call a WCF Webservice, from a dll I have made, running
Am getting an error mentioned below when I call my WCF service?How do i
I am trying to call a WCF service from a Silverlight client using channel
I'm trying to call a web service from .NET 3.5 using WCF. The error
I am trying to call a WCF RESTful service from jQuery. I am using
I am trying to call the stored procedure using subsonic and getting Object Reference
I'm trying to call a stored procedure from my .NET code which has one
I have a WCF service which I'm trying to call from a simple .NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.