SocketAsyncEventArgs.SocketClientAccessPolicyProtocol Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the method to download the policy file that an instance of the Socket class will use.

Namespace:  System.Net.Sockets
Assembly:  System.Net (in System.Net.dll)

Syntax

'Declaration
Public Property SocketClientAccessPolicyProtocol As SocketClientAccessPolicyProtocol
public SocketClientAccessPolicyProtocol SocketClientAccessPolicyProtocol { get; set; }

Property Value

Type: System.Net.Sockets.SocketClientAccessPolicyProtocol
The method to download the policy file that an instance of the Socket class will use. The default is Tcp.

Remarks

The security policy system in the Silverlight runtime requires that a policy file be downloaded from a network resource before a network connection is allowed to access that resource. For network connections using System.Net.Sockets, the security policy system in Silverlight affects both site-of-origin and cross-domain network access. A security policy is required for any connections using sockets, even when the connection is back to the site of origin. For more information on the security policy system in Silverlight, see Network Security Access Restrictions in Silverlight.

In Silverlight 3 for a connection request using System.Net.Sockets to the site (cross-domain or site of origin), the Silverlight runtime tries to open a connection using TCP to a well-known port (port 943) on the target site. If a TCP connection can be established, the Silverlight runtime sends a special string to the server to request a Silverlight policy file for use by System.Net.Sockets. The Silverlight runtime then waits to receive a reply from the target site that contains a Silverlight policy file. If this Silverlight policy file is returned (even if there is an error in parsing the file), it is used as the policy file for that socket request and all subsequent requests to that target site for the entire session of the Silverlight application.

In Silverlight 4 for a connection request using System.Net.Sockets, an application can choose instead to retrieve the policy file via the HTTP protocol on TCP port 80 instead of the custom TCP protocol on port 943. The socket policy file can be stored in the same "clientaccesspolicy.xml" file at the root of the requested target domain that is used for cross-domain network access by the WebClient and HTTP classes in the System.Net namespace. This allows HTTP servers that are already running HTTP services to authorize socket connections from Silverlight applications without having to deploy a new TCP server service on the machine and open a port through a firewall for port 943.

To use HTTP to retrieve the socket policy file, an application should set the SocketClientAccessPolicyProtocol property to SocketClientAccessPolicyProtocol.Http on the SocketAsyncEventArgs instance passed to the Socket.ConnectAsync method.

To use TCP and port 943 to retrieve the socket policy file, an application should set the SocketClientAccessPolicyProtocol property to SocketClientAccessPolicyProtocol.Tcp on the SocketAsyncEventArgs instance passed to the Socket.ConnectAsync method.

The SocketAsyncEventArgs for a SocketAsyncEventArgs sets the default value for the SocketClientAccessPolicyProtocol property to SocketClientAccessPolicyProtocol.Tcp.

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.