I've got a silverlight client, using SL4, and a C# server using .NET 4. The server opens a port on 4525, to which the client is intended to connect. Now, if I can ask that you simply read the following, we can probably avoid me having to post any further code:
The client attempts to make the connection to the server, opens up the connection for the policy file, requests the policy file, and gets returned the policy file. What is not happening, is the onConnect event in the client. Before I implemented a policy server, the client would connect on 4525, and execute the onConnect event, but immediately fail because there was no policy server. Now that I have implemented the policy server, it appears that it never detects the finalization of its delivery.
Here is the transmission summary:
Client:
<policy-file-request/>
Server:
<?xml version="1.0" encoding ="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from>
<domain uri="*:4525" />
</allow-from>
<grant-to>
<socket-resource port="4525" protocol="tcp" />
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
Effectively; the only question I am trying to answer is this: Am I missing something from my policy file, or do I need to conclude its submission to the client in any particular manner, in order for my client to detect its delivery?
Things of note:
The Client successfully establishes its connection to the policy server
The policy server successfully writes the policy back to the client
The 'real' servers port is successfully opened
The client 'can' connect to the 'real' server
Thank you all for your time, I am sure someone will be able to help.
Code Request Client Connection
Not sure that it's of any further consequence toward finding an answer; but:
private static DnsEndPoint IP_END_POINT = new DnsEndPoint("192.168.0.36", 4525, AddressFamily.InterNetwork);
public MainPage()
{
try
{
InitializeComponent();
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
SocketAsyncEventArgs connectEventArgs = new SocketAsyncEventArgs();
connectEventArgs.RemoteEndPoint = IP_END_POINT;
connectEventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(ConnectionEstablished);
socket.ConnectAsync(connectEventArgs);
}
catch (Exception e)
{
}
}
New Development 'Connection Established' fires!
So it turns out that if I want a minute or so, my 'ConnectionEstablished' event does eventually fire. What I get from it, however, is not so encouraging.
I ended up with a SocketError of 'AccessDenied', and a message of 'An attempt was made to access a socket in a way forbidden by its access permissions.', and as can be expected, my server never accepts the connection. I know that the server has the port open, and can accept a connection, so this is quite the perplexing scenario.
Thanks again for anyone's help.