Language

DatagramSocketControl クラス

定義

DatagramSocket オブジェクトのソケット コントロール データを提供します。

public ref class DatagramSocketControl sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class DatagramSocketControl final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class DatagramSocketControl
Public NotInheritable Class DatagramSocketControl
継承
Object Platform::Object IInspectable DatagramSocketControl
属性

Windows の要件

要件 説明
デバイス ファミリ
Windows 10 (10.0.10240.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v1.0 で導入)

注釈

DatagramSocketControl クラスを使用すると、 DatagramSocket オブジェクトの高度なソケット制御データにアクセスできます。

DatagramSocketControl オブジェクトは、親 DatagramSocket オブジェクトを使用して自動的に作成されます。 DatagramSocket.Control プロパティは、関連付けられている DatagramSocketControl オブジェクトへのアクセスを提供します。

OutboundUnicastHopLimit プロパティは、DatagramSocket がバインドまたは接続される前または後に設定できます。 バインドされた DatagramSocket または接続された DatagramSocket でこの値を変更する前に、以前に書き込まれたすべてのデータが前のホップ制限で確実に送信されるように、送信パケットをフラッシュする必要があります。

DatagramSocketControl の他のプロパティ値に対する変更は、 DatagramSocket がバインドまたは接続される前に設定する必要があります。 その結果、DontFragment、InboundBufferSizeInBytes、または QualityOfService プロパティを変更する必要がある場合、これらの変更は、DatagramSocket で BindEndpointAsync、BindServiceNameAsync、またはいずれかの ConnectAsync メソッドを正常に呼び出す前に発生する必要があります。

次の例では、 DatagramSocket を作成し、 QualityOfService プロパティを LowLatency に設定する方法を示します。 他のプロパティも同様の方法で設定できます。 これが完了すると、アプリは DatagramSocket に接続したり、ソケットでデータを送信したりできます。

using Windows.Networking.Sockets;

DatagramSocket clientSocket = new DatagramSocket();

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

// Set QualityOfService to LowLatency.
clientSocket.Control.QualityOfService = SocketQualityOfService.LowLatency;

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

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

// Set QualityOfService to LowLatency.
clientSocket.Control().QualityOfService(Windows::Networking::Sockets::SocketQualityOfService::LowLatency);

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

DatagramSocket^ clientSocket = ref new DatagramSocket();

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

// Set QualityOfService to LowLatency.
clientSocket->Control->QualityOfService = SocketQualityOfService::LowLatency;

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

DatagramSocketControl の使用方法の詳細については、「 高度なソケット コントロールを使用する方法」を参照してください。

プロパティ

Name 説明
DontFragment

DatagramSocket で UDP の IP データグラムをフラグメント化できるかどうかを指定するブール値を取得または設定します。

InboundBufferSizeInBytes

DatagramSocket オブジェクトのデータを受信するために使用されるバッファーのサイズをバイト単位で取得または設定します。

MulticastOnly

DatagramSocket が同じアドレス/ポートにバインドされている他の Win32 または WinRT マルチキャスト ソケットと共存できるかどうかを指定するブール値を取得または設定します。

OutboundUnicastHopLimit

DatagramSocket オブジェクトによってユニキャスト IP アドレスに送信される送信パケットのホップ制限を取得または設定します。

QualityOfService

DatagramSocket オブジェクトのサービス品質を取得または設定します。

適用対象

関連項目