IUdpClientSender.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.Collections.Generic;
  15. using System.Net;
  16. using System.Net.Sockets;
  17. using System.Threading.Tasks;
  18. namespace TouchSocket.Sockets
  19. {
  20. /// <summary>
  21. /// 具有Udp终结点的发送
  22. /// </summary>
  23. public interface IUdpClientSender : ISender
  24. {
  25. /// <summary>
  26. /// 同步组合发送数据。
  27. /// <para>内部已经封装Ssl和发送长度检测,即:调用完成即表示数据全部发送完毕。</para>
  28. /// <para>该发送会经过适配器封装,具体封装内容由适配器决定。</para>
  29. /// </summary>
  30. /// <param name="endPoint">远程终结点</param>
  31. /// <param name="transferBytes">组合数据</param>
  32. /// <exception cref="NotConnectedException">客户端没有连接</exception>
  33. /// <exception cref="OverlengthException">发送数据超长</exception>
  34. /// <exception cref="Exception">其他异常</exception>
  35. void Send(EndPoint endPoint, IList<ArraySegment<byte>> transferBytes);
  36. /// <summary>
  37. /// 异步组合发送数据。
  38. /// <para>在<see cref="ITcpClient"/>时,如果使用独立线程发送,则不会触发异常。</para>
  39. /// <para>在<see cref="ITcpClientBase"/>时,相当于<see cref="Socket.BeginSend(byte[], int, int, SocketFlags, out SocketError, System.AsyncCallback, object)"/>。</para>
  40. /// <para>该发送会经过适配器封装,具体封装内容由适配器决定。</para>
  41. /// </summary>
  42. /// <param name="endPoint">远程终结点</param>
  43. /// <param name="transferBytes">组合数据</param>
  44. /// <exception cref="NotConnectedException">客户端没有连接</exception>
  45. /// <exception cref="OverlengthException">发送数据超长</exception>
  46. /// <exception cref="Exception">其他异常</exception>
  47. Task SendAsync(EndPoint endPoint, IList<ArraySegment<byte>> transferBytes);
  48. /// <summary>
  49. /// 同步组合发送数据。
  50. /// <para>内部已经封装Ssl和发送长度检测,即:调用完成即表示数据全部发送完毕。</para>
  51. /// <para>该发送会经过适配器封装,具体封装内容由适配器决定。</para>
  52. /// </summary>
  53. /// <param name="endPoint">远程终结点</param>
  54. /// <param name="buffer"></param>
  55. /// <param name="offset"></param>
  56. /// <param name="length"></param>
  57. /// <exception cref="OverlengthException">发送数据超长</exception>
  58. /// <exception cref="Exception">其他异常</exception>
  59. void Send(EndPoint endPoint, byte[] buffer, int offset, int length);
  60. /// <summary>
  61. /// 异步组合发送数据。
  62. /// <para>在<see cref="ITcpClient"/>时,如果使用独立线程发送,则不会触发异常。</para>
  63. /// <para>在<see cref="ITcpClientBase"/>时,相当于<see cref="Socket.BeginSend(byte[], int, int, SocketFlags, out SocketError, System.AsyncCallback, object)"/>。</para>
  64. /// <para>该发送会经过适配器封装,具体封装内容由适配器决定。</para>
  65. /// </summary>
  66. /// <param name="endPoint">远程终结点</param>
  67. /// <param name="buffer"></param>
  68. /// <param name="offset"></param>
  69. /// <param name="length"></param>
  70. /// <exception cref="OverlengthException">发送数据超长</exception>
  71. /// <exception cref="Exception">其他异常</exception>
  72. Task SendAsync(EndPoint endPoint, byte[] buffer, int offset, int length);
  73. }
  74. }