LingerOption.cs 892 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // System.Net.Sockets.LingerOption.cs
  3. //
  4. // Author:
  5. // Andrew Sutton
  6. //
  7. // (C) Andrew Sutton
  8. //
  9. using System;
  10. namespace System.Net.Sockets
  11. {
  12. // <remarks>
  13. // Encapsulates a linger option.
  14. // </remarks>
  15. public class LingerOption
  16. {
  17. protected bool enabled;
  18. protected int seconds;
  19. public LingerOption (bool enable, int secs)
  20. {
  21. enabled = enable;
  22. seconds = secs;
  23. }
  24. public bool Enabled
  25. {
  26. get { return enabled; }
  27. set { enabled = value; }
  28. }
  29. public int LingerTime
  30. {
  31. get { return seconds; }
  32. set { seconds = value; }
  33. }
  34. public override bool Equals (object o)
  35. {
  36. return (enabled == o.enabled) && (seconds == o.seconds);
  37. }
  38. public override int GetHashCode()
  39. {
  40. return seconds;
  41. }
  42. public string ToString()
  43. {
  44. string ret;
  45. if (enabled) {
  46. ret = "off";
  47. }
  48. else {
  49. ret = seconds.ToString();
  50. }
  51. return ret;
  52. }
  53. }
  54. }