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 之前,必须设置对 StreamSocketListener 属性值 所做的任何更改。 因此,在 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 |
一个 值,该值指示是否应在 StreamSocket 对象接收连接时创建的 StreamSocket 对象上发送保持连接数据包。 |
NoDelay |
一个 值,该值指示是否在 StreamSocketListener 对象收到连接时创建的 StreamSocket 对象上使用 Nagle 算法。 |
OutboundBufferSizeInBytes |
在 StreamSocketListener 对象接收连接时创建的 StreamSocket 对象上发送数据的发送缓冲区的大小(以字节为单位)。 |
OutboundUnicastHopLimit |
StreamSocketListener 对象接收连接时创建的 StreamSocket 对象发送到单播 IP 地址的出站数据包的跃点限制。 |
QualityOfService |
StreamSocketListener 对象接收连接时创建的 StreamSocket 对象上要设置的服务质量。 |