StreamSocketControl Kelas

Definisi

Menyediakan data kontrol soket pada objek StreamSocket .

public ref class StreamSocketControl sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class StreamSocketControl final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class StreamSocketControl
Public NotInheritable Class StreamSocketControl
Warisan
Object Platform::Object IInspectable StreamSocketControl
Atribut

Persyaratan Windows

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

Keterangan

Kelas StreamSocketControl menyediakan akses ke data kontrol soket tingkat lanjut pada objek StreamSocket .

Objek StreamSocketControl secara otomatis dibuat dengan objek StreamSocket induk. Properti StreamSocket.Control menyediakan akses ke objek StreamSocketControl terkait.

Setiap perubahan pada nilai properti pada StreamSocketControl harus diatur sebelum StreamSocket tersambung. Akibatnya jika Anda perlu membuat perubahan pada properti ClientCertificate, IgnorableServerCertificateErrors, KeepAlive, NoDelay, OutboundBufferSizeInBytes , OutboundUnicastHopLimit, atau QualityOfService , maka perubahan ini harus terjadi sebelum panggilan berhasil ke salah satu metode ConnectAsync di StreamSocket.

Gunakan ClientCertificate untuk mengatur sertifikat klien yang akan digunakan untuk membuat koneksi aman melalui objek StreamSocket terkait.

Contoh berikut membuat StreamSocket, lalu menunjukkan cara mengatur properti NoDelay ke false. Properti lain mungkin diatur dengan cara yang sama. Setelah ini selesai, aplikasi dapat menghubungkan StreamSocket.

using Windows.Networking.Sockets;

StreamSocket clientSocket = new StreamSocket();

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

// Set NoDelay to false so that the Nagle algorithm is not disabled.
clientSocket.Control.NoDelay = false;

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

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

// Set NoDelay to false so that the Nagle algorithm is not disabled.
clientSocket.Control().NoDelay(false);

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

StreamSocket^ clientSocket = ref new StreamSocket();

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

// Set NoDelay to false so that the Nagle algorithm is not disabled.
clientSocket->Control->NoDelay = false;

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

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

Riwayat versi

Versi Windows Versi SDK Nilai ditambahkan
1709 16299 MinProtectionLevel

Properti

ClientCertificate

Mendapatkan atau mengatur sertifikat SSL/TLS klien yang akan dikirim ke server jika server meminta sertifikat klien.

IgnorableServerCertificateErrors

Dapatkan vektor kesalahan server SSL untuk diabaikan saat membuat koneksi SSL dengan StreamSocket.

KeepAlive

Nilai yang menunjukkan apakah paket tetap hidup dikirim ke tujuan jarak jauh pada objek StreamSocket .

MinProtectionLevel

Membatasi versi protokol TLS yang akan dinegosiasikan ketika pengembang menggunakan metode ConnectAsync() atau UpgradeToSslAsync() yang memerlukan TLS.

NoDelay

Nilai yang menunjukkan apakah algoritma Nagle digunakan pada objek StreamSocket .

OutboundBufferSizeInBytes

Ukuran, dalam byte, dari buffer kirim yang akan digunakan untuk mengirim data pada objek StreamSocket .

OutboundUnicastHopLimit

Batas hop pada paket keluar yang dikirim ke alamat IP unicast oleh objek StreamSocket .

QualityOfService

Kualitas layanan pada objek StreamSocket .

SerializeConnectionAttempts

Nilai yang menunjukkan apakah, ketika beberapa upaya koneksi sedang dilakukan, upaya dilakukan secara paralel atau serial.

Berlaku untuk

Lihat juga