Share via


StreamWebSocketControl Class

Definition

Provides socket control data on a StreamWebSocket object.

public ref class StreamWebSocketControl sealed
public ref class StreamWebSocketControl sealed : IWebSocketControl2
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class StreamWebSocketControl final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class StreamWebSocketControl final : IWebSocketControl2
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class StreamWebSocketControl
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class StreamWebSocketControl : IWebSocketControl2
Public NotInheritable Class StreamWebSocketControl
Public NotInheritable Class StreamWebSocketControl
Implements IWebSocketControl2
Inheritance
Object Platform::Object IInspectable StreamWebSocketControl
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)
App capabilities
internetClient privateNetworkClientServer

Remarks

The StreamWebSocketControl class provides access to advanced socket control data on a StreamWebSocket object.

A StreamWebSocketControl object is automatically created with the parent StreamWebSocket object. The StreamWebSocket.Control property provides access to the associated StreamWebSocketControl object.

Any changes to the StreamWebSocketControl property values must be set before the StreamWebSocket is connected. As a result if you need to make changes to the NoDelay, OutboundBufferSizeInBytes, ProxyCredential, ServerCredential, or SupportedProtocols properties, then these changes must occur before a successful call to the ConnectAsync method on the StreamWebSocket.

The following example creates a StreamWebSocket, and then demonstrates how to set the StreamWebSocketControl.NoDelay property to false. (Other properties may be set in a similar manner.) After this is done, the app can connect the StreamWebSocket.

using Windows.Networking.Sockets;

StreamWebSocket clientWebSocket = new StreamWebSocket();

// Get the current setting for this option.
// This isn't required, but it shows how to get the current setting.
bool currentSetting = clientWebSocket.Control.NoDelay;

// Set NoDelay to false so that the Nagle algorithm is not disabled.
clientWebSocket.Control.NoDelay = false;

// Now you can call the ConnectAsync method to connect the StreamWebSocket.
#include <winrt/Windows.Networking.Sockets.h>
using namespace winrt;
...
Windows::Networking::Sockets::StreamWebSocket clientWebSocket;

// Get the current setting for this option.
// This isn't required, but it shows how to get the current setting.
bool currentSetting{ clientWebSocket.Control().NoDelay() };

// Set NoDelay to false so that the Nagle algorithm is not disabled.
clientWebSocket.Control().NoDelay(false);

// Now you can call the ConnectAsync method to connect the StreamWebSocket.
using namespace Windows::Networking::Sockets;

StreamWebSocket^ clientWebSocket = ref new StreamWebSocket();

// Get the current setting for this option.
// This isn't required, but it shows how to get the current setting .
bool currentSetting = clientWebSocket->Control->NoDelay;

// Set NoDelay to false so that the Nagle algorithm is not disabled.
clientWebSocket->Control->NoDelay = false;

// Now you can call the ConnectAsync method to connect the StreamWebSocket.

For more information about using StreamWebSocketControl, see How to use advanced WebSocket controls.

Version history

Windows version SDK version Value added
1607 14393 IgnorableServerCertificateErrors
1709 16299 ActualUnsolicitedPongInterval
1709 16299 ClientCertificate
1709 16299 DesiredUnsolicitedPongInterval

Properties

ActualUnsolicitedPongInterval

Allows an app to get the actual unsolicited WebSocket PONG interval.

ClientCertificate

Gets the certificate provided by the client when a secure WebSocket connection has been established.

DesiredUnsolicitedPongInterval

Allows an app to get and set the desired unsolicited WebSocket PONG interval.

IgnorableServerCertificateErrors

Gets a list of ignorable server certificate errors. Get this list and add ChainValidationResult values for server certificate errors that you wish to ignore during the secure WebSocket (wss:// protocol) server certificate validation process.

NoDelay

A value that indicates whether the Nagle algorithm is used on a StreamWebSocket object.

OutboundBufferSizeInBytes

The size, in bytes, of the send buffer to be used for sending data on a StreamWebSocket object.

ProxyCredential

The credential to use to authenticate to the proxy server through HTTP header authentication using a StreamWebSocket object.

ServerCredential

The credential to use to authenticate to the WebSocket server through HTTP header authentication using a StreamWebSocket object.

SupportedProtocols

Gets a collection that can be used to add a list of supported sub-protocols that will be advertised to the server during the connect handshake.

Applies to