Compartir a través de


SocketClientAccessPolicyProtocol Enumeration

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

Specifies 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 Enumeration SocketClientAccessPolicyProtocol
public enum SocketClientAccessPolicyProtocol

Members

Member name Description
Tcp The Socket class will attempt to download the socket policy file using custom TCP protocol running on TCP port 943.
Http The Socket class will attempt to download the socket policy file using HTTP.

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 SocketAsyncEventArgs.SocketClientAccessPolicyProtocol property to Http on the System.Net.Sockets.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 SocketAsyncEventArgs.SocketClientAccessPolicyProtocol property to Tcp on the System.Net.Sockets.SocketAsyncEventArgs instance passed to the Socket.ConnectAsync method.

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.