/windows.networking.sockets/streamwebsocketcontrol.md

https://github.com/MicrosoftDocs/winrt-api · Markdown · 97 lines · 66 code · 31 blank · 0 comment · 0 complexity · 015a9cf39c7b1c114a6a720e96fa4eae MD5 · raw file

  1. ---
  2. -api-id: T:Windows.Networking.Sockets.StreamWebSocketControl
  3. -api-type: winrt class
  4. ---
  5. <!-- Class syntax.
  6. public class StreamWebSocketControl : Windows.Networking.Sockets.IStreamWebSocketControl, Windows.Networking.Sockets.IWebSocketControl, Windows.Networking.Sockets.IWebSocketControl2
  7. -->
  8. # Windows.Networking.Sockets.StreamWebSocketControl
  9. ## -description
  10. Provides socket control data on a [StreamWebSocket](streamwebsocket.md) object.
  11. ## -remarks
  12. The StreamWebSocketControl class provides access to advanced socket control data on a [StreamWebSocket](streamwebsocket.md) object.
  13. A StreamWebSocketControl object is automatically created with the parent [StreamWebSocket](streamwebsocket.md) object. The [StreamWebSocket.Control](streamwebsocket_control.md) property provides access to the associated StreamWebSocketControl object.
  14. Any changes to the StreamWebSocketControl property values must be set before the [StreamWebSocket](streamwebsocket.md) is connected. As a result if you need to make changes to the [NoDelay](streamwebsocketcontrol_nodelay.md), [OutboundBufferSizeInBytes](streamwebsocketcontrol_outboundbuffersizeinbytes.md), [ProxyCredential](streamwebsocketcontrol_proxycredential.md), [ServerCredential](streamwebsocketcontrol_servercredential.md), or [SupportedProtocols](streamwebsocketcontrol_supportedprotocols.md) properties, then these changes must occur before a successful call to the [ConnectAsync](streamsocket_connectasync_13692504.md) method on the [StreamWebSocket](streamwebsocket.md).
  15. The following example creates a [StreamWebSocket](streamwebsocket.md), and then demonstrates how to set the [StreamWebSocketControl.NoDelay](streamwebsocketcontrol_nodelay.md) property to **false**. (Other properties may be set in a similar manner.) After this is done, the app can connect the [StreamWebSocket](streamwebsocket.md).
  16. ```csharp
  17. using Windows.Networking.Sockets;
  18. StreamWebSocket clientWebSocket = new StreamWebSocket();
  19. // Get the current setting for this option.
  20. // This isn't required, but it shows how to get the current setting.
  21. bool currentSetting = clientWebSocket.Control.NoDelay;
  22. // Set NoDelay to false so that the Nagle algorithm is not disabled.
  23. clientWebSocket.Control.NoDelay = false;
  24. // Now you can call the ConnectAsync method to connect the StreamWebSocket.
  25. ```
  26. ```cppwinrt
  27. #include <winrt/Windows.Networking.Sockets.h>
  28. using namespace winrt;
  29. ...
  30. Windows::Networking::Sockets::StreamWebSocket clientWebSocket;
  31. // Get the current setting for this option.
  32. // This isn't required, but it shows how to get the current setting.
  33. bool currentSetting{ clientWebSocket.Control().NoDelay() };
  34. // Set NoDelay to false so that the Nagle algorithm is not disabled.
  35. clientWebSocket.Control().NoDelay(false);
  36. // Now you can call the ConnectAsync method to connect the StreamWebSocket.
  37. ```
  38. ```cppcx
  39. using namespace Windows::Networking::Sockets;
  40. StreamWebSocket^ clientWebSocket = ref new StreamWebSocket();
  41. // Get the current setting for this option.
  42. // This isn't required, but it shows how to get the current setting .
  43. bool currentSetting = clientWebSocket->Control->NoDelay;
  44. // Set NoDelay to false so that the Nagle algorithm is not disabled.
  45. clientWebSocket->Control->NoDelay = false;
  46. // Now you can call the ConnectAsync method to connect the StreamWebSocket.
  47. ```
  48. For more information about using StreamWebSocketControl, see [How to use advanced WebSocket controls](/previous-versions/windows/apps/hh994400(v=win.10)).
  49. ### Version history
  50. | Windows version | SDK version | Value added |
  51. | -- | -- | -- |
  52. | 1607 | 14393 | IgnorableServerCertificateErrors |
  53. | 1709 | 16299 | ActualUnsolicitedPongInterval |
  54. | 1709 | 16299 | ClientCertificate |
  55. | 1709 | 16299 | DesiredUnsolicitedPongInterval |
  56. ## -examples
  57. ## -see-also
  58. [How to use advanced WebSocket controls](/previous-versions/windows/apps/hh994400(v=win.10)),
  59. [StreamWebSocket](streamwebsocket.md),
  60. StreamWebSocketControl,
  61. [StreamWebSocketInformation](streamwebsocketinformation.md),
  62. [WebSockets](/windows/uwp/networking/websockets?branch=live),
  63. [WebSocket sample](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/WebSocket),
  64. [ControlChannelTrigger StreamWebSocket sample](https://github.com/microsoftarchive/msdn-code-gallery-microsoft/tree/master/Official%20Windows%20Platform%20Sample/Windows%208.1%20Store%20app%20samples/%5BC%23%5D-Windows%208.1%20Store%20app%20samples/ControlChannelTrigger%20StreamWebSocket%20sample/C%23)
  65. ## -capabilities
  66. internetClient, privateNetworkClientServer