Provides access to sockets and WebSockets for network communications and real-time notifications to be received in the background for connected apps.
The Windows.Networking.Sockets namespace has these types of members:
The Windows.Networking.Sockets namespace has these classes.
|ControlChannelTrigger||Enables real time notifications to be received in the background for class elements in the Windows.Networking.Sockets namespace and other networking transports.|
|DatagramSocket||Supports network communication using a UDP datagram socket.|
|DatagramSocketControl||Provides socket control data on a DatagramSocket object.|
|DatagramSocketInformation||Provides socket information on a DatagramSocket object.|
|DatagramSocketMessageReceivedEventArgs||Provides data for a MessageReceived 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.|
|SocketError||Provides socket error status for operations on a DatagramSocket, StreamSocket, or StreamSocketListener.|
|StreamSocket||Supports network communication using a TCP stream socket.|
|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.|
|StreamSocketListenerConnectionReceivedEventArgs||Provides data for a ConnectionReceived event on a StreamSocketListener object.|
|StreamSocketListenerControl||Provides socket control data on a StreamSocketListener object.|
|StreamSocketListenerInformation||Provides socket information on a StreamSocketListener object.|
|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.|
|WebSocketClosedEventArgs||Provides data for a closed event on a MessageWebSocket, StreamWebSocket, or IWebSocket object.|
|WebSocketError||Provides socket error status on a MessageWebSocket or StreamWebSocket object.|
|WebSocketKeepAlive||Provides the ability to send a WebSocket protocol keep-alive on a connected WebSocket.|
The Windows.Networking.Sockets namespace has these enumerations.
|ControlChannelTriggerResetReason||The reason why a ControlChannelTrigger was reset.|
|ControlChannelTriggerResourceType||The resource type used by a control channel trigger.|
|ControlChannelTriggerStatus||Specifies if the system was able to complete configuration of a ControlChannelTrigger object for use by class elements in the Windows.Networking.Sockets and related namespaces.|
|SocketErrorStatus||Specifies status values for a socket operation.|
|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.|
The Windows.Networking.Sockets namespace defines these interfaces.
|IControlChannelTriggerEventDetails||An object instantiated by the background broker infrastructure that is used to differentiate control channel triggers.|
|IControlChannelTriggerResetEventDetails||An object instantiated by the background broker infrastructure for a ControlChannelReset event to indicate that a ControlChannelTrigger was reset.|
|IWebSocket||Provides access to network communication that allows reading and writing using a WebSocket.|
|IWebSocketControl||Provides socket control data on an IWebSocket object.|
|IWebSocketInformation||Provides socket information on an IWebSocket object.|
The Windows.Networking.Sockets namespace has these structures.
|BandwidthStatistics||Represents bandwidth information for network data transfer using a StreamSocket, StreamWebSocket, or MessageWebSocket object.|
|RoundTripTimeStatistics||Represents round trip time information for a StreamSocket object.|
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.
On Windows Server 2012, 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 (which is the default on Windows Server 2012).
The Media Foundation feature can be enabled on Windows Server 2012 using Server Manager or by entering the following text in a command prompt or a script:
dism /online /enable-feature /featurename:ServerMediaFoundation
After the Media Foundation feature is enabled on Windows Server 2012, the user is prompted to restart. Once the computer is restarted, classes used for sockets and WebSockets in the Windows.Networking.Sockets namespace will work as expected.
The network isolation feature in Windows 8 enables a developer to fully control the security profile of a Windows Store app.
Network isolation allows a developer to define the scope of required network access for each app by selecting the appropriate capabilities. 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 even an app does become compromised, it will only be able to access networks where the app has explicitly been granted access. This significantly reduces the scope of the impact on other applications and on the operating system.
Windows 8 actively enforces network isolation. A call to a method or any access to a property in the Windows.Networking.Sockets namespace (or related namespaces that require network access) may fail 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 by using Visual Studio when developing the app. They may also be set manually in the app manifest file by using a text editor.
For more detailed information on network isolation, see How to configure network isolation capabilities.
The Windows.Networking.Sockets namespace provides support for network control channel triggers that are used to enable real-time status and notifications for class elements in the Windows.Networking.Sockets namespace and in related namespaces.
Network triggers are used by long-running network apps (for example, an email app) to minimize network and system resource usage. Network triggers allow an app to drop to a low-power mode for periods of time, keeping network connections intact but in a low-power state. An app can set a keep-alive interval to let the system know when the app should wake up. An app can also set a trigger to let it be notified when a packet is received for the app. These notification features can help extend battery life when using long-running network apps on mobile devices.
Minimum supported client
Minimum supported server
|Windows Server 2012|
Minimum supported phone
|Windows Phone 8|
- Other resources
- Adding support for networking
- Connecting to network services
- Connecting to a WebSocket service
- How to configure network isolation capabilities
- How to set background connectivity options
- Troubleshooting and debugging network connections
- Windows.Networking Namespace
- Windows.Networking.Connectivity Namespace
- Connecting with WebSockets sample
- ControlChannelTrigger TCP socket sample
- StreamSocket sample
Build date: 2/25/2013