StateObject.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Net.Sockets;
  4. using System.Text;
  5. namespace TFT_MelsecMcNet
  6. {
  7. /// <summary>
  8. /// 网络中的异步对象
  9. /// </summary>
  10. internal class StateObject : StateOneBase
  11. {
  12. #region Constructor
  13. /// <summary>
  14. /// 实例化一个对象
  15. /// </summary>
  16. public StateObject()
  17. {
  18. }
  19. /// <summary>
  20. /// 实例化一个对象,指定接收或是发送的数据长度
  21. /// </summary>
  22. /// <param name="length">数据长度</param>
  23. public StateObject(int length)
  24. {
  25. DataLength = length;
  26. Buffer = new byte[length];
  27. }
  28. #endregion
  29. #region Public Member
  30. /// <summary>
  31. /// 唯一的一串信息
  32. /// </summary>
  33. public string UniqueId { get; set; }
  34. /// <summary>
  35. /// 网络套接字
  36. /// </summary>
  37. public TcpClient WorkSocket { get; set; }
  38. /// <summary>
  39. /// 是否关闭了通道
  40. /// </summary>
  41. public bool IsClose { get; set; }
  42. #endregion
  43. #region Public Method
  44. /// <summary>
  45. /// 清空旧的数据
  46. /// </summary>
  47. public void Clear()
  48. {
  49. IsError = false;
  50. IsClose = false;
  51. AlreadyDealLength = 0;
  52. Buffer = null;
  53. }
  54. #endregion
  55. }
  56. }