Windows.Networking.Sockets namespace

Expand
1 out of 1 rated this helpful Rate this topic

Windows.Networking.Sockets namespace

[This documentation is preliminary and is subject to change.]

Provides access to sockets and WebSockets for network communications.

Members

The Windows.Networking.Sockets namespace has the following types of members:

Classes

The Windows.Networking.Sockets namespace has the following classes.

ClassDescription
AcceptOperation Manages an asynchronous accept operation on a StreamSocketListener.
DatagramSocket Supports network communication using a UDP datagram socket.
DatagramSocketBindOperation Manages an asynchronous bind operation on a DatagramSocket.
DatagramSocketConnectOperation Manages an asynchronous connect operation on a DatagramSocket.
DatagramSocketInformation Provides socket information about a DatagramSocket.
DatagramSocketMessageReceivedEventArgs Provides data for a message received event on a DatagramSocket.
MessageWebSocket Supports network communication that allows reading and writing whole messages using a WebSocket.
MessageWebSocketControl Provides socket control data on a MessageWebSocket.
MessageWebSocketInformation Provides socket information on a MessageWebSocket.
MessageWebSocketMessageReceivedEventArgs Provides data for a message received event on a MessageWebSocket.
NotificationChannel Supports the creation and use of notification channels to enable real-time status and notifications for class elements in the Windows.Networking.Sockets namespace.
StreamSocket Supports network communication using a TCP stream socket.
StreamSocketConnectOperation Manages an asynchronous connect operation on a StreamSocket.
StreamSocketControl Provides socket control data on a StreamSocket object.
StreamSocketInformation Provides socket information on a StreamSocket object.
StreamSocketListener Supports listening for an incoming network connection using a TCP stream socket.
StreamWebSocket Supports network communication that allows reading and writing streams using a WebSocket.
StreamWebSocketControl Provides socket control data on a StreamWebSocket object.
StreamWebSocketInformation Provides socket information on a StreamWebSocket object.
UpgradeToSslOperation Manages an asynchronous operation to upgrade to use SSL on a StreamSocket object.
WebSocketConnectOperation Manages an asynchronous connect operation on a MessageWebSocket or StreamWebSocket object.

 

Delegates

The Windows.Networking.Sockets namespace has the following delegates.

DelegateDescription
DatagramSocketMessageReceivedEventHandler Represents a method that handles the message received event on a DatagramSocket.
ListenerStartedEventHandler Represents a method that handles the listener started event on a StreamSocketListener.
MessageWebSocketMessageReceivedEventHandler Represents a method that handles the message received event on a MessageWebSocket.

 

Enumerations

The Windows.Networking.Sockets namespace has the following enumerations.

EnumerationDescription
NotificationChannelStatus Specifies if the system was able to correctly set up a NotificationChannel object for use by class elements in the Windows.Networking.Sockets namespace.
SocketMessageType Specifies the type of a message for a MessageWebSocket object.
SocketProtectionLevel Specifies the protection level that represents the integrity and encryption for a StreamSocket object.
SocketQualityOfService Specifies the quality of service for a DatagramSocket or StreamSocket object.

 

Interface implementations

The Windows.Networking.Sockets namespace implements the following interfaces.

InterfaceDescription
INotificationChannel Supports the creation and use of notification channels to enable real-time status and notifications for class elements in the Windows.Networking.Sockets namespace.
INotificationChannelEventDetails An object instantiated by the background broker infrastructure that is used to differentiate notification channels.
INotificationChannelFactory Creates an INotificationChannel.
IStreamSocket Provides access to network communication that allows reading and writing using a StreamSocket.
IStreamSocketListenerFactory Creates a StreamSocketListener.
IWebSocket Provides access to network communication that allows reading and writing using a WebSocket.

 

Structures

The Windows.Networking.Sockets namespace has the following structures.

StructureDescription
BandwidthStatistics Represents bandwidth information for network data transfer using a StreamSocket, StreamWebSocket, or a MessageWebSocket object.
RoundTripTimeStatistics Represents round trip time information for a StreamSocket object.

 

Remarks

The Windows.Networking.Sockets namespace provides classes and interfaces for networking that use sockets and WebSockets. The primary classes include the following:

  • DatagramSocket - Used to support network communication using a UDP datagram socket.
  • StreamSocket - Used to support network communication using a TCP stream socket.
  • StreamSocketListener - Used to support listening for an incoming network connection using a TCP stream socket.
  • MessageWebSocket - Used to support network communication that allows reading and writing whole messages using a WebSocket.
  • StreamWebSocket - Used to support network communication that allows reading and writing streams using a WebSocket.

The primary classes listed above also have a number of related support classes in the Windows.Networking.Sockets namespace used with these classes.

The Windows.Networking.Sockets namespace also provides support for notification channels that are used to enable real-time status and notifications for class elements in the Windows.Networking.Sockets and related namespaces. Notification channels are used by long-running network apps to minimize network and system resource usage (an email app that is left running, for example). Notifications allow an app to drop to a low-power mode for periods of time while still keeping network connections intact but in a low-power state. An app can set a keep-alive interval used by the system for when the app and the network connections used should wake up. These notification features would commonly be used by long-running network apps targeted for mobile devices to extend battery life. For more information, see the NotificationChannel and related classes.

On Windows Server Developer Preview, the Windows.Networking.dll that implements most of the classes in the Windows.Networking.Sockets namespace will fail to load unless the Media Foundation feature is enabled. As a result, apps using classes used for sockets and WebSockets in the Windows.Networking.Sockets namespace will fail if the Media Foundation feature is disabled (the default on Windows Server Developer Preview).

The Media Foundation feature can be enabled on Windows Server Developer Preview using Server Manager or by entering the follow command in a CMD window or a script.

dism /online /enable-feature /featurename:ServerMediaFoundation

The user is prompted to reboot after the Media Foundation feature is enabled on Windows Server Developer Preview. Once the computer is rebooted, classes used for sockets and WebSockets in the Windows.Networking.Sockets namespace will work as expected.

Using sockets and WebSockets with network isolation

The network isolation feature in Windows Developer Preview enables a developer to fully control the security profile of a Metro style app. Not all apps may require access to the network. However for those apps that do, the Windows Developer Preview provides different levels of access to the network that can be enabled by selecting appropriate capabilities.

Network isolation allows a developer to define for each app the scope of required network access. An app without the appropriate scope defined is prevented from accessing the specified type of network, and specific type of network request (outbound client-initiated requests or both inbound unsolicited requests and outbound client-initiated requests). The ability to set and enforce network isolation ensures that if an app does get compromised, it can only access networks where the app has explicitly been granted access. This significantly reduces the scope of the impact on other applications and on Windows.

Network isolation affects any methods and properties in the Windows.Networking.Sockets and related namespaces that try to access the network. Windows actively enforces network isolation. A call to a method or any access to a property in the Windows.Networking.Sockets namespace that results in network access may fail because of network isolation if the appropriate network capability has not been enabled.

The network capabilities for an app are configured in the app manifest when the app is built. Network capabilities are usually added using Visual Studio when developing the app. Network capabilities may also be set manually in the app manifest file using a text editor.

For more detailed information on network isolation, see the Guidelines and checklist for network isolation.

Requirements

Minimum supported client

Windows Developer Preview

Minimum supported server

Windows Server Developer Preview

Namespace

Windows.Networking.Sockets

Assembly

Windows.Networking.dll
Windows.Networking.Sockets.Pushenabledapplication.dll

See also

Guidelines and checklist for network isolation
Windows.Networking Namespace
Windows.Networking.Connectivity Namespace

 

 

Build date: 9/7/2011

Did you find this helpful?
(1500 characters remaining)
Community Additions ADD