StreamSocketControl 類別

定義

提供 StreamSocket 物件上的套接字控制數據。

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
繼承
Object Platform::Object IInspectable StreamSocketControl
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)
應用程式功能
bluetooth.rfcomm ID_CAP_NETWORKING [Windows Phone]

備註

StreamSocketControl 類別可讓您存取 StreamSocket 物件上的進階套接字控制數據。

StreamSocketControl 物件會自動使用父 StreamSocket 物件建立。 StreamSocket.Control 屬性可讓您存取相關聯的 StreamSocketControl 物件。

必須先設定 StreamSocketControl 上屬性值的任何變更, 才能連接 StreamSocket 。 因此,如果您需要變更 ClientCertificateIgnorableServerCertificateErrorsKeepAliveNoDelayOutboundBufferSizeInBytesOutboundUnicastHopLimitQualityOfService 属性,則必須在成功呼叫 StreamSocket 上的其中一個 ConnectAsync 方法之前發生這些變更。

使用 ClientCertificate 來設定用來透過相關聯 StreamSocket 物件建立安全連線的客戶端憑證。

下列範例會建立 StreamSocket,然後示範如何將 NoDelay 屬性設定為 false。 其他屬性可能會以類似的方式設定。 完成此動作之後,應用程式就可以連線 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.

如需使用 StreamSocketControl 的詳細資訊,請參閱 如何使用進階套接字控件

版本歷程記錄

Windows 版本 SDK 版本 已新增值
1709 16299 MinProtectionLevel

屬性

ClientCertificate

取得或設定用戶端 SSL/TLS 憑證,如果伺服器要求用戶端憑證,則會傳送至伺服器。

IgnorableServerCertificateErrors

取得使用 StreamSocket 進行 SSL 連線時要忽略的 SSL 伺服器錯誤的向量。

KeepAlive

值,指出是否將保持運作封包傳送至 StreamSocket 對象的遠端目的地。

MinProtectionLevel

限制當開發人員使用 ConnectAsync () 或 UpgradeToSslAsync () 需要 TLS 的方法時,將會交涉的 TLS 通訊協定版本。

NoDelay

值,指出 Nagle 演算法是否用於 StreamSocket 物件。

OutboundBufferSizeInBytes

要用於在 StreamSocket 物件上傳送數據的傳送緩衝區大小,以位元組為單位。

OutboundUnicastHopLimit

StreamSocket 物件傳送至單播 IP 位址之輸出封包的躍點限制。

QualityOfService

StreamSocket 物件上的服務品質。

SerializeConnectionAttempts

值,指出在進行多個連線嘗試時,會平行或序列進行嘗試。

適用於

另請參閱