IWaitSender.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //------------------------------------------------------------------------------
  2. // 此代码版权(除特别声明或在XREF结尾的命名空间的代码)归作者本人若汝棋茗所有
  3. // 源代码使用协议遵循本仓库的开源协议及附加协议,若本仓库没有设置,则按MIT开源协议授权
  4. // CSDN博客:https://blog.csdn.net/qq_40374647
  5. // 哔哩哔哩视频:https://space.bilibili.com/94253567
  6. // Gitee源代码仓库:https://gitee.com/RRQM_Home
  7. // Github源代码仓库:https://github.com/RRQM
  8. // API首页:https://www.yuque.com/rrqm/touchsocket/index
  9. // 交流QQ群:234762506
  10. // 感谢您的下载和使用
  11. //------------------------------------------------------------------------------
  12. //------------------------------------------------------------------------------
  13. using System;
  14. using System.Threading;
  15. using System.Threading.Tasks;
  16. using TouchSocket.Core;
  17. namespace TouchSocket.Sockets
  18. {
  19. /// <summary>
  20. /// 发送等待接口
  21. /// </summary>
  22. public interface IWaitSender : ISenderBase
  23. {
  24. /// <summary>
  25. /// 发送字节流
  26. /// </summary>
  27. /// <param name="buffer">数据缓存区</param>
  28. /// <param name="offset">偏移</param>
  29. /// <param name="length">长度</param>
  30. /// <param name="timeout">超时时间</param>
  31. /// <param name="token">取消令箭</param>
  32. /// <exception cref="NotConnectedException">客户端没有连接</exception>
  33. /// <exception cref="OverlengthException">发送数据超长</exception>
  34. /// <exception cref="Exception">其他异常</exception>
  35. /// <returns>返回的数据</returns>
  36. byte[] SendThenReturn(byte[] buffer, int offset, int length, int timeout = 1000 * 5, CancellationToken token = default);
  37. /// <summary>
  38. /// 发送字节流
  39. /// </summary>
  40. /// <param name="buffer">数据缓存区</param>
  41. /// <param name="timeout">超时时间</param>
  42. /// <param name="token">取消令箭</param>
  43. /// <exception cref="NotConnectedException">客户端没有连接</exception>
  44. /// <exception cref="OverlengthException">发送数据超长</exception>
  45. /// <exception cref="Exception">其他异常</exception>
  46. /// <returns>返回的数据</returns>
  47. byte[] SendThenReturn(byte[] buffer, int timeout = 1000 * 5, CancellationToken token = default);
  48. /// <summary>
  49. /// 发送流中的有效数据
  50. /// </summary>
  51. /// <param name="byteBlock">数据块载体</param>
  52. /// <param name="timeout">超时时间</param>
  53. /// <param name="token">取消令箭</param>
  54. /// <exception cref="NotConnectedException">客户端没有连接</exception>
  55. /// <exception cref="OverlengthException">发送数据超长</exception>
  56. /// <exception cref="Exception">其他异常</exception>
  57. /// <returns>返回的数据</returns>
  58. byte[] SendThenReturn(ByteBlock byteBlock, int timeout = 1000 * 5, CancellationToken token = default);
  59. /// <summary>
  60. /// 异步发送
  61. /// </summary>
  62. /// <param name="buffer">数据缓存区</param>
  63. /// <param name="offset">偏移</param>
  64. /// <param name="length">长度</param>
  65. /// <param name="timeout">超时时间</param>
  66. /// <param name="token">取消令箭</param>
  67. /// <exception cref="NotConnectedException">客户端没有连接</exception>
  68. /// <exception cref="OverlengthException">发送数据超长</exception>
  69. /// <exception cref="Exception">其他异常</exception>
  70. /// <returns>返回的数据</returns>
  71. Task<byte[]> SendThenReturnAsync(byte[] buffer, int offset, int length, int timeout = 1000 * 5, CancellationToken token = default);
  72. /// <summary>
  73. /// 异步发送
  74. /// </summary>
  75. /// <param name="buffer">数据缓存区</param>
  76. /// <param name="timeout">超时时间</param>
  77. /// <param name="token">取消令箭</param>
  78. /// <exception cref="NotConnectedException">客户端没有连接</exception>
  79. /// <exception cref="OverlengthException">发送数据超长</exception>
  80. /// <exception cref="Exception">其他异常</exception>
  81. /// <returns>返回的数据</returns>
  82. Task<byte[]> SendThenReturnAsync(byte[] buffer, int timeout = 1000 * 5, CancellationToken token = default);
  83. /// <summary>
  84. /// 异步发送
  85. /// </summary>
  86. /// <param name="byteBlock">数据块载体</param>
  87. /// <param name="timeout">超时时间</param>
  88. /// <param name="token">取消令箭</param>
  89. /// <exception cref="NotConnectedException">客户端没有连接</exception>
  90. /// <exception cref="OverlengthException">发送数据超长</exception>
  91. /// <exception cref="Exception">其他异常</exception>
  92. /// <returns>返回的数据</returns>
  93. Task<byte[]> SendThenReturnAsync(ByteBlock byteBlock, int timeout = 1000 * 5, CancellationToken token = default);
  94. }
  95. }