Condividi tramite


StreamSocketControl Classe

Definizione

Fornisce i dati di controllo socket in un oggetto 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
Ereditarietà
Object Platform::Object IInspectable StreamSocketControl
Attributi

Requisiti Windows

Famiglia di dispositivi
Windows 10 (è stato introdotto in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (è stato introdotto in v1.0)
Funzionalità dell'app
bluetooth.rfcomm ID_CAP_NETWORKING [Windows Phone]

Commenti

La classe StreamSocketControl fornisce l'accesso ai dati di controllo socket avanzati in un oggetto StreamSocket .

Un oggetto StreamSocketControl viene creato automaticamente con l'oggetto StreamSocket padre. La proprietà StreamSocket.Control fornisce l'accesso all'oggetto StreamSocketControl associato.

Le modifiche ai valori delle proprietà in StreamSocketControl devono essere impostate prima della connessione di StreamSocket. Di conseguenza, se è necessario apportare modifiche alle proprietà ClientCertificate, IgnoraableServerCertificateErrors, KeepAlive, NoDelay, OutboundBufferSizeInBytes , OutboundUnicastHopLimit o QualityOfService , queste modifiche devono verificarsi prima di una chiamata corretta a uno dei metodi ConnectAsync nel StreamSocket.

Usare ClientCertificate per impostare un certificato client da usare per creare connessioni sicure sull'oggetto StreamSocket associato.

Nell'esempio seguente viene creato un oggetto StreamSocket e viene illustrato come impostare la proprietà NoDelay su false. Altre proprietà possono essere impostate in modo analogo. Al termine, l'app può connettere 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.

Per altre informazioni sull'uso di StreamSocketControl, vedere Come usare i controlli socket avanzati.

Cronologia delle versioni

Versione di Windows Versione dell'SDK Valore aggiunto
1709 16299 MinProtectionLevel

Proprietà

ClientCertificate

Ottiene o imposta il certificato SSL/TLS client che verrà inviato al server se il server richiede un certificato client.

IgnorableServerCertificateErrors

Ottenere un vettore di errori del server SSL da ignorare quando si effettua una connessione SSL con un streamSocket.

KeepAlive

Valore che indica se i pacchetti keep-alive vengono inviati alla destinazione remota in un oggetto StreamSocket .

MinProtectionLevel

Limita la versione del protocollo TLS che verrà negoziata quando lo sviluppatore usa i metodi ConnectAsync() o UpgradeToSslAsync() che richiedono TLS.

NoDelay

Valore che indica se l'algoritmo Nagle viene usato in un oggetto StreamSocket .

OutboundBufferSizeInBytes

Dimensioni, in byte, del buffer di invio da usare per l'invio di dati in un oggetto StreamSocket .

OutboundUnicastHopLimit

Limite di hop su un pacchetto in uscita inviato a un indirizzo IP unicast dall'oggetto StreamSocket .

QualityOfService

Qualità del servizio in un oggetto StreamSocket .

SerializeConnectionAttempts

Valore che indica se vengono eseguiti più tentativi di connessione, i tentativi vengono effettuati in parallelo o serialmente.

Si applica a

Vedi anche