WatsonTcpKeepaliveSettings.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. namespace WatsonTcp
  2. {
  3. using System;
  4. /// <summary>
  5. /// WatsonTcp keepalive settings. WatsonTcp does not implement keepalives, rather, it relies on the underlying implementation in the operating system and runtime.
  6. /// Keepalive probes are sent after an idle period defined by TcpKeepAliveTime (seconds).
  7. /// Should a keepalive response not be received within TcpKeepAliveInterval (seconds), a subsequent keepalive probe will be sent.
  8. /// For .NET Framework, should 10 keepalive probes fail, the connection will terminate.
  9. /// For .NET Core, should a number of probes fail as specified in TcpKeepAliveRetryCount, the connection will terminate.
  10. /// TCP keepalives are not supported in .NET Standard.
  11. /// </summary>
  12. public class WatsonTcpKeepaliveSettings
  13. {
  14. #region Public-Members
  15. /// <summary>
  16. /// Enable or disable TCP-based keepalive probes.
  17. /// WatsonTcp does not implement keepalives, rather, it relies on the underlying implementation in the operating system and runtime.
  18. /// TCP keepalives are only supported in .NET Core and .NET Framework projects. .NET Standard does not provide facilities to support TCP keepalives.
  19. /// </summary>
  20. public bool EnableTcpKeepAlives = false;
  21. /// <summary>
  22. /// TCP keepalive interval, i.e. the number of seconds a TCP connection will wait for a keepalive response before sending another keepalive probe.
  23. /// WatsonTcp does not implement keepalives, rather, it relies on the underlying implementation in the operating system and runtime.
  24. /// Default is 5 seconds. Value must be greater than zero.
  25. /// </summary>
  26. public int TcpKeepAliveInterval
  27. {
  28. get
  29. {
  30. return _TcpKeepAliveInterval;
  31. }
  32. set
  33. {
  34. if (value < 1) throw new ArgumentException("TcpKeepAliveInterval must be greater than zero.");
  35. _TcpKeepAliveInterval = value;
  36. }
  37. }
  38. /// <summary>
  39. /// TCP keepalive time, i.e. the number of seconds a TCP connection will remain alive/idle before keepalive probes are sent to the remote.
  40. /// WatsonTcp does not implement keepalives, rather, it relies on the underlying implementation in the operating system and runtime.
  41. /// Default is 5 seconds. Value must be greater than zero.
  42. /// </summary>
  43. public int TcpKeepAliveTime
  44. {
  45. get
  46. {
  47. return _TcpKeepAliveTime;
  48. }
  49. set
  50. {
  51. if (value < 1) throw new ArgumentException("TcpKeepAliveTime must be greater than zero.");
  52. _TcpKeepAliveTime = value;
  53. }
  54. }
  55. /// <summary>
  56. /// TCP keepalive retry count, i.e. the number of times a TCP probe will be sent in effort to verify the connection.
  57. /// WatsonTcp does not implement keepalives, rather, it relies on the underlying implementation in the operating system and runtime.
  58. /// After the specified number of probes fail, the connection will be terminated.
  59. /// </summary>
  60. public int TcpKeepAliveRetryCount
  61. {
  62. get
  63. {
  64. return _TcpKeepAliveRetryCount;
  65. }
  66. set
  67. {
  68. if (value < 1) throw new ArgumentException("TcpKeepAliveRetryCount must be greater than zero.");
  69. _TcpKeepAliveRetryCount = value;
  70. }
  71. }
  72. #endregion
  73. #region Private-Members
  74. private int _TcpKeepAliveInterval = 5;
  75. private int _TcpKeepAliveTime = 5;
  76. private int _TcpKeepAliveRetryCount = 5;
  77. #endregion
  78. #region Constructors-and-Factories
  79. /// <summary>
  80. /// Instantiate.
  81. /// </summary>
  82. public WatsonTcpKeepaliveSettings()
  83. {
  84. }
  85. #endregion
  86. #region Public-Methods
  87. #endregion
  88. #region Private-Methods
  89. #endregion
  90. }
  91. }