/windows.networking.sockets/streamsocketcontrol.md

https://github.com/MicrosoftDocs/winrt-api · Markdown · 86 lines · 58 code · 28 blank · 0 comment · 0 complexity · 16c55f1eeb8c2fb3b3e71b8d1770c4a9 MD5 · raw file

  1. ---
  2. -api-id: T:Windows.Networking.Sockets.StreamSocketControl
  3. -api-type: winrt class
  4. ---
  5. <!-- Class syntax.
  6. public class StreamSocketControl : Windows.Networking.Sockets.IStreamSocketControl, Windows.Networking.Sockets.IStreamSocketControl2, Windows.Networking.Sockets.IStreamSocketControl3
  7. -->
  8. # Windows.Networking.Sockets.StreamSocketControl
  9. ## -description
  10. Provides socket control data on a [StreamSocket](streamsocket.md) object.
  11. ## -remarks
  12. The StreamSocketControl class provides access to advanced socket control data on a [StreamSocket](streamsocket.md) object.
  13. A StreamSocketControl object is automatically created with the parent [StreamSocket](streamsocket.md) object. The [StreamSocket.Control](streamsocket_control.md) property provides access to the associated StreamSocketControl object.
  14. Any changes to the property values on the StreamSocketControl must be set before the [StreamSocket](streamsocket.md) is connected. As a result if you need to make changes to the [ClientCertificate](streamsocketcontrol_clientcertificate.md), [IgnorableServerCertificateErrors](streamsocketcontrol_ignorableservercertificateerrors.md), [KeepAlive](streamsocketcontrol_keepalive.md), [NoDelay](streamsocketcontrol_nodelay.md), [OutboundBufferSizeInBytes](streamsocketcontrol_outboundbuffersizeinbytes.md) , [OutboundUnicastHopLimit](streamsocketcontrol_outboundunicasthoplimit.md), or [QualityOfService](streamsocketcontrol_qualityofservice.md) properties, then these changes must occur before a successful call to one of the [ConnectAsync](streamsocket_connectasync_13692504.md) methods on the [StreamSocket](streamsocket.md).
  15. Use the [ClientCertificate](streamsocketcontrol_clientcertificate.md) to set a client certificate to be used to make secure connections over the associated [StreamSocket](streamsocket.md) object.
  16. The following example creates a [StreamSocket](streamsocket.md), and then demonstrates how to set the [NoDelay](streamsocketcontrol_nodelay.md) property to **false**. Other properties may be set in a similar manner. After this is done, the app can connect the [StreamSocket](streamsocket.md).
  17. ```csharp
  18. using Windows.Networking.Sockets;
  19. StreamSocket clientSocket = new StreamSocket();
  20. // Get the current setting for this option.
  21. // This isn't required, but it shows how to get the current setting.
  22. bool currentSetting = clientSocket.Control.NoDelay;
  23. // Set NoDelay to false so that the Nagle algorithm is not disabled.
  24. clientSocket.Control.NoDelay = false;
  25. // Now you can call the ConnectAsync method to connect the StreamSocket.
  26. ```
  27. ```cppwinrt
  28. #include <winrt/Windows.Networking.Sockets.h>
  29. using namespace winrt;
  30. ...
  31. Windows::Networking::Sockets::StreamSocket clientSocket;
  32. // Get the current setting for this option.
  33. // This isn't required, but it shows how to get the current setting.
  34. bool currentSetting{ clientSocket.Control().NoDelay() };
  35. // Set NoDelay to false so that the Nagle algorithm is not disabled.
  36. clientSocket.Control().NoDelay(false);
  37. // Now you can call the ConnectAsync function to connect the StreamSocket.
  38. ```
  39. ```cppcx
  40. using namespace Windows::Networking::Sockets;
  41. StreamSocket^ clientSocket = ref new StreamSocket();
  42. // Get the current setting for this option.
  43. // This isn't required, but it shows how to get the current setting.
  44. bool currentSetting = clientSocket->Control->NoDelay;
  45. // Set NoDelay to false so that the Nagle algorithm is not disabled.
  46. clientSocket->Control->NoDelay = false;
  47. // Now you can call the ConnectAsync method to connect the StreamSocket.
  48. ```
  49. For more information on using StreamSocketControl, see [How to use advanced socket controls](/previous-versions/windows/apps/jj150598(v=win.10)).
  50. ### Version history
  51. | Windows version | SDK version | Value added |
  52. | -- | -- | -- |
  53. | 1709 | 16299 | MinProtectionLevel |
  54. ## -examples
  55. ## -see-also
  56. [Connecting with sockets](/previous-versions/windows/apps/hh452976(v=win.10)), [How to use advanced socket controls](/previous-versions/windows/apps/jj150598(v=win.10)), [StreamSocket](streamsocket.md), [StreamSocket.Control](streamsocket_control.md), [StreamSocketInformation](datagramsocketinformation.md), [ControlChannelTrigger StreamSocket 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%20StreamSocket%20sample/C%23), [StreamSocket sample](/samples/browse/)
  57. ## -capabilities
  58. ID_CAP_NETWORKING [Windows Phone], bluetooth.rfcomm