StreamSocketListenerControl 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
在 StreamSocketListener 物件上提供套接字控制數據。
public ref class StreamSocketListenerControl sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class StreamSocketListenerControl final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class StreamSocketListenerControl
Public NotInheritable Class StreamSocketListenerControl
- 繼承
- 屬性
Windows 需求
裝置系列 |
Windows 10 (已於 10.0.10240.0 引進)
|
API contract |
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)
|
應用程式功能 |
ID_CAP_NETWORKING [Windows Phone]
|
備註
StreamSocketListenerControl 類別可讓您存取 StreamSocketListener 物件上的進階套接字控制數據。
StreamSocketListenerControl 物件會自動使用父 StreamSocketListener 物件建立。 StreamSocketListener.Control 屬性可讓您存取相關聯的 StreamSocketListenerControl 物件。
在 StreamSocketListener 系結之前,必須先設定 StreamSocketListenerControl 屬性值的任何變更。 因此在 StreamSocketListener 上呼叫 BindServiceNameAsync 或 BindEndpointAsync 方法之前,必須先設定 QualityOfService 屬性的變更。
下列範例會建立 StreamSocketListener,然後示範如何將 QualityOfService 屬性設定為 LowLatency。 完成此動作之後,應用程式就可以系結並接聽 StreamSocketListener。
using Windows.Networking.Sockets;
StreamSocketListener listenerSocket = new StreamSocketListener();
// Get the current setting for this option.
// This isn't required, but it shows how to get the current setting.
var currentSetting = listenerSocket.Control.QualityOfService;
// Set QualityOfService to LowLatency.
listenerSocket.Control.QualityOfService = SocketQualityOfService.LowLatency;
// Now you can call the BindServiceNameAsync or BindEndpointAsync method to listen for connections.
#include <winrt/Windows.Networking.Sockets.h>
using namespace winrt;
...
Windows::Networking::Sockets::StreamSocketListener listenerSocket;
// Get the current setting for this option.
// This isn't required, but it shows how to get the current setting.
auto currentSetting{ listenerSocket.Control().QualityOfService() };
// Set QualityOfService to LowLatency.
listenerSocket.Control().QualityOfService(Windows::Networking::Sockets::SocketQualityOfService::LowLatency);
// Now you can call the BindServiceNameAsync or BindEndpointAsync method to listen for connections.
using namespace Windows::Networking::Sockets;
StreamSocketListener^ listenerSocket = ref new StreamSocketListener();
// Get the current setting for this option.
// This isn't required, but it shows how to get the current setting.
auto currentSetting = listenerSocket->Control->QualityOfService;
// Set QualityOfService to LowLatency.
listenerSocket->Control->QualityOfService = SocketQualityOfService::LowLatency;
// Now you can call the BindServiceNameAsync or BindEndpointAsync method to listen for connections.
如需使用 StreamSocketListenerControl 的詳細資訊,請參閱 如何使用進階套接字控件。
屬性
KeepAlive |
值,指出 StreamSocketListener 物件收到連線時,是否應該在 StreamSocket 對象上傳送保持連線封包。 |
NoDelay |
值,指出當 StreamSocketListener 物件收到連接時,是否要在建立的 StreamSocket 物件上使用 Nagle 演算法。 |
OutboundBufferSizeInBytes |
當 StreamSocketListener 物件收到連接時所建立之 StreamSocket 物件上所建立之傳送緩衝區的大小,以位元組為單位。 |
OutboundUnicastHopLimit |
StreamSocketListener 物件收到連線時所建立之 StreamSocket 物件傳送至單播 IP 位址的輸出封包躍點限制。 |
QualityOfService |
當 StreamSocketListener 物件收到連接時,要在 StreamSocket 對象上設定的服務品質。 |