StateObject.cs 1.5 KB

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