The Socket class provides a set of methods and properties for network communications. The Socket class allows you to perform asynchronous data transfer using any of the communication protocols listed in the ProtocolType enumeration. Currently, the only supported ProtocolType is the TCP protocol.
When you are finished sending and receiving data, use the Shutdown method to disable the Socket. After calling Shutdown, call the Close method to release all resources associated with the Socket.
Normally, a client will initiate a connection to the host from which the web page with the XAML application was downloaded. One method that can be used to determine the host name from which the web page was downloaded is to use the System.Windows..::.Application class in the System.Windows namespace to get the Application..::.Current property of the Silverlight application. This property returns a System.Windows.Interop..::.SilverlightHost instance for the Silverlight application. The SilverlightHost..::.Source property on this instance gets the Uri used to connect to the host. The Uri..::.Host property gets the host component of this instance. This host component can then be used with a port number to construct a new DnsEndPoint instance by calling one of the DnsEndPoint constructors.
If the XAP file for the XAML application was loaded using a Uri of Uri..::.UriSchemeFile to a file on the local computer, the SilverlightHost..::.Source property is set to a Uri with the Uri..::.Scheme property set to Uri..::.UriSchemeFile and the Uri..::.Host property will not be valid for use in a System.Net..::.DnsEndPoint.
If the XAP file for the XAML application was loaded using a Uri of Uri..::.UriSchemeHttp to a web page on the local computer, the SilverlightHost..::.Source property is set to a Uri with the Uri..::.Scheme property set to Uri..::.UriSchemeHttp and the Uri..::.Host property is set to localhost.
For sockets, the security policy system in Silverlight version 2 and later affects both site-of-origin and cross-domain network access. A security policy is required for any connections from 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.