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에서 도입되었습니다.)
앱 기능
ID_CAP_NETWORKING [Windows Phone]

설명

DatagramSocketControl 클래스는 DatagramSocket 개체의 고급 소켓 제어 데이터에 대한 액세스를 제공합니다.

부모 DatagramSocket 개체를 사용하여 DatagramSocketControl 개체가 자동으로 만들어집니다. DatagramSocket.Control 속성은 연결된 DatagramSocketControl 개체에 대한 액세스를 제공합니다.

OutboundUnicastHopLimit 속성은 DatagramSocket이 바인딩되거나 연결되기 전이나 후에 설정할 수 있습니다. 바인딩되거나 연결된 DatagramSocket에서 이 값을 변경하기 전에 먼저 나가는 패킷을 플러시하여 이전에 작성된 모든 데이터가 이전 홉 제한으로 전송되도록 해야 합니다.

DatagramSocketControl의 다른 속성 값에 대한 변경 내용은 DatagramSocket 이 바인딩되거나 연결되기 전에 설정해야 합니다. 따라서 DontFragment, InboundBufferSizeInBytes 또는 QualityOfService 속성을 변경해야 하는 경우 이러한 변경 내용은 BindEndpointAsync, BindServiceNameAsync 또는 DatagramSocketConnectAsync 메서드 중 하나를 성공적으로 호출하기 전에 발생해야 합니다.

다음 예제에서는 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 사용에 대한 자세한 내용은 고급 소켓 컨트롤을 사용하는 방법을 참조하세요.

속성

DontFragment

DatagramSocket에서 UDP에 대한 IP 데이터그램을 조각화할 수 있는지 여부를 지정하는 부울 값을 가져오거나 설정합니다.

InboundBufferSizeInBytes

DatagramSocket 개체에서 데이터를 수신하는 데 사용되는 버퍼의 크기(바이트)를 가져오거나 설정합니다.

MulticastOnly

DatagramSocket이 동일한 주소/포트에 바인딩된 다른 Win32 또는 WinRT 멀티캐스트 소켓과 공존할 수 있는지 여부를 지정하는 부울 값을 가져오거나 설정합니다.

OutboundUnicastHopLimit

DatagramSocket 개체가 유니캐스트 IP 주소로 보낸 아웃바운드 패킷의 홉 제한을 가져오거나 설정합니다.

QualityOfService

DatagramSocket 개체의 서비스 품질을 가져오거나 설정합니다.

적용 대상

추가 정보