StreamSocketControl Classe
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Fornece dados de controle de soquete em um objeto 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
- Herança
- Atributos
Requisitos do Windows
| Família de dispositivos |
Windows 10 (introduzida na 10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduzida na v1.0)
|
| Funcionalidades do aplicativo |
bluetooth.rfcomm
ID_CAP_NETWORKING [Windows Phone]
|
Comentários
A classe StreamSocketControl fornece acesso a dados avançados de controle de soquete em um objeto StreamSocket .
Um objeto StreamSocketControl é criado automaticamente com o objeto StreamSocket pai. A propriedade StreamSocket.Control fornece acesso ao objeto StreamSocketControl associado.
Todas as alterações nos valores de propriedade no StreamSocketControl devem ser definidas antes que o StreamSocket seja conectado. Como resultado, se você precisar fazer alterações nas propriedades ClientCertificate, IgnorableServerCertificateErrors, KeepAlive, NoDelay, OutboundBufferSizeInBytes , OutboundUnicastHopLimit ou QualityOfService , essas alterações deverão ocorrer antes de uma chamada bem-sucedida para um dos métodos ConnectAsync no StreamSocket.
Use o ClientCertificate para definir um certificado de cliente a ser usado para fazer conexões seguras pelo objeto StreamSocket associado.
O exemplo a seguir cria um StreamSocket e demonstra como definir a propriedade NoDelay como false. Outras propriedades podem ser definidas de maneira semelhante. Depois que isso for feito, o aplicativo poderá conectar o 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.
Para obter mais informações sobre como usar StreamSocketControl, consulte Como usar controles de soquete avançados.
Histórico de versão
| Versão do Windows | Versão do SDK | Valor adicionado |
|---|---|---|
| 1.709 | 16299 | MinProtectionLevel |
Propriedades
| ClientCertificate |
Obtém ou define o certificado SSL/TLS do cliente que será enviado ao servidor se o servidor solicitar um certificado de cliente. |
| IgnorableServerCertificateErrors |
Obtenha um vetor de erros do servidor SSL a ser ignorado ao fazer uma conexão SSL com um StreamSocket. |
| KeepAlive |
Um valor que indica se os pacotes keep alive são enviados para o destino remoto em um objeto StreamSocket . |
| MinProtectionLevel |
Restringe a versão do protocolo TLS que será negociada quando o desenvolvedor usar os métodos ConnectAsync() ou UpgradeToSslAsync() que exigem TLS. |
| NoDelay |
Um valor que indica se o algoritmo Nagle é usado em um objeto StreamSocket . |
| OutboundBufferSizeInBytes |
O tamanho, em bytes, do buffer de envio a ser usado para enviar dados em um objeto StreamSocket . |
| OutboundUnicastHopLimit |
O limite de salto em um pacote de saída enviado para um endereço IP unicast pelo objeto StreamSocket . |
| QualityOfService |
A qualidade do serviço em um objeto StreamSocket . |
| SerializeConnectionAttempts |
Um valor que indica se, quando várias tentativas de conexão estão sendo feitas, as tentativas são feitas em paralelo ou em série. |