DatagramSocketControl Kelas

Definisi

Menyediakan data kontrol soket pada objek 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
Warisan
Object Platform::Object IInspectable DatagramSocketControl
Atribut

Persyaratan Windows

Rangkaian perangkat
Windows 10 (diperkenalkan dalam 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v1.0)
Kemampuan aplikasi
ID_CAP_NETWORKING [Windows Phone]

Keterangan

Kelas DatagramSocketControl menyediakan akses ke data kontrol soket tingkat lanjut pada objek DatagramSocket .

Objek DatagramSocketControl secara otomatis dibuat dengan objek DatagramSocket induk. Properti DatagramSocket.Control menyediakan akses ke objek DatagramSocketControl terkait.

Properti OutboundUnicastHopLimit dapat diatur sebelum atau sesudah DatagramSocket terikat atau tersambung. Sebelum mengubah nilai ini pada DatagramSocket terikat atau terhubung, paket keluar apa pun harus terlebih dahulu dihapus untuk memastikan bahwa semua data yang ditulis sebelumnya dikirim dengan batas hop sebelumnya.

Setiap perubahan pada nilai properti lain pada DatagramSocketControl harus diatur sebelum DatagramSocket terikat atau tersambung. Akibatnya jika Anda perlu membuat perubahan pada properti DontFragment, InboundBufferSizeInBytes, atau QualityOfService , maka perubahan ini harus terjadi sebelum panggilan berhasil ke BindEndpointAsync, BindServiceNameAsync, atau salah satu metode ConnectAsync pada DatagramSocket.

Contoh berikut membuat DatagramSocket, lalu menunjukkan cara mengatur properti QualityOfService ke LowLatency. Properti lain mungkin diatur dengan cara yang sama. Setelah ini selesai, aplikasi dapat menyambungkan DatagramSocket atau mengirim data di soket.

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.

Untuk informasi selengkapnya tentang menggunakan DatagramSocketControl, lihat Cara menggunakan kontrol soket tingkat lanjut.

Properti

DontFragment

Mendapatkan atau menetapkan nilai Boolean yang menentukan apakah DatagramSocket memungkinkan datagram IP untuk UDP terfragmentasi.

InboundBufferSizeInBytes

Mendapatkan atau mengatur ukuran, dalam byte, dari buffer yang digunakan untuk menerima data pada objek DatagramSocket .

MulticastOnly

Mendapatkan atau menetapkan nilai Boolean yang menentukan apakah DatagramSocket dapat berdampingan dengan soket multicast Win32 atau WinRT lainnya yang terikat ke alamat/port yang sama.

OutboundUnicastHopLimit

Mendapatkan atau menetapkan batas hop pada paket keluar yang dikirim ke alamat IP unicast oleh objek DatagramSocket .

QualityOfService

Mendapatkan atau mengatur kualitas layanan pada objek DatagramSocket .

Berlaku untuk

Lihat juga