StreamSocketControl Class

Definition

Provides socket control data on a StreamSocket object.

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

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)
App capabilities
bluetooth.rfcomm ID_CAP_NETWORKING [Windows Phone]

Remarks

The StreamSocketControl class provides access to advanced socket control data on a StreamSocket object.

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

Any changes to the property values on the StreamSocketControl must be set before the StreamSocket is connected. As a result if you need to make changes to the ClientCertificate, IgnorableServerCertificateErrors, KeepAlive, NoDelay, OutboundBufferSizeInBytes , OutboundUnicastHopLimit, or QualityOfService properties, then these changes must occur before a successful call to one of the ConnectAsync methods on the StreamSocket.

Use the ClientCertificate to set a client certificate to be used to make secure connections over the associated StreamSocket object.

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

using Windows.Networking.Sockets;

StreamSocket clientSocket = new StreamSocket();

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

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

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

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

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

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

StreamSocket^ clientSocket = ref new StreamSocket();

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

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

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

For more information on using StreamSocketControl, see How to use advanced socket controls.

Version history

Windows version SDK version Value added
1709 16299 MinProtectionLevel

Properties

ClientCertificate

Gets or sets the client SSL/TLS certificate that will be sent to the server if the server requests a client certificate.

IgnorableServerCertificateErrors

Get a vector of SSL server errors to ignore when making an SSL connection with a StreamSocket.

KeepAlive

A value that indicates whether keep-alive packets are sent to the remote destination on a StreamSocket object.

MinProtectionLevel

Constrains the TLS protocol version that will be negotiated when the developer uses the ConnectAsync() or UpgradeToSslAsync() methods that require TLS.

NoDelay

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

OutboundBufferSizeInBytes

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

OutboundUnicastHopLimit

The hop limit on an outbound packet sent to a unicast IP address by the StreamSocket object.

QualityOfService

The quality of service on a StreamSocket object.

SerializeConnectionAttempts

A value that indicates whether, when multiple connection attempts are being made, the attempts are made in parallel or serially.

Applies to

See also