Udostępnij za pośrednictwem


StreamSocketListenerControl Class

Definition

Provides socket control data on a StreamSocketListener object.

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
Inheritance
Object Platform::Object IInspectable StreamSocketListenerControl
Attributes

Windows requirements

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

Remarks

The StreamSocketListenerControl class provides access to advanced socket control data on a StreamSocketListener object.

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

Any changes to the StreamSocketListenerControl property values must be set before the StreamSocketListener is bound. So changes to the QualityOfService property must be set before the BindServiceNameAsync or BindEndpointAsync method is called on the StreamSocketListener.

The following example creates a StreamSocketListener, and then demonstrates how to set the QualityOfService property to LowLatency. After this is done, the app can bind and listen on the 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.

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

Properties

KeepAlive

A value that indicates whether keep-alive packets should be sent on a StreamSocket object created when a connection is received by the StreamSocketListener object.

NoDelay

A value that indicates whether the Nagle algorithm is used on a StreamSocket object created when a connection is received by the StreamSocketListener object.

OutboundBufferSizeInBytes

The size, in bytes, of the send buffer to be used for sending data on a StreamSocket object created when a connection is received by the StreamSocketListener object.

OutboundUnicastHopLimit

The hop limit on an outbound packet sent to a unicast IP address by the StreamSocket object created when a connection is received by the StreamSocketListener object.

QualityOfService

The quality of service to be set on a StreamSocket object created when a connection is received by the StreamSocketListener object.

Applies to

See also