ISocket.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. namespace MediaBrowser.Model.Net
  8. {
  9. /// <summary>
  10. /// Provides a common interface across platforms for UDP sockets used by this SSDP implementation.
  11. /// </summary>
  12. public interface ISocket : IDisposable
  13. {
  14. IpAddressInfo LocalIPAddress { get; }
  15. /// <summary>
  16. /// Waits for and returns the next UDP message sent to this socket (uni or multicast).
  17. /// </summary>
  18. /// <returns></returns>
  19. Task<SocketReceiveResult> ReceiveAsync(CancellationToken cancellationToken);
  20. Task<SocketReceiveResult> ReceiveAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken);
  21. IAsyncResult BeginReceive(byte[] buffer, int offset, int count, AsyncCallback callback);
  22. SocketReceiveResult EndReceive(IAsyncResult result);
  23. /// <summary>
  24. /// Sends a UDP message to a particular end point (uni or multicast).
  25. /// </summary>
  26. Task SendToAsync(byte[] buffer, int offset, int bytes, IpEndPointInfo endPoint, CancellationToken cancellationToken);
  27. IAsyncResult BeginSendTo(byte[] buffer, int offset, int size, IpEndPointInfo endPoint, AsyncCallback callback, object state);
  28. int EndSendTo(IAsyncResult result);
  29. }
  30. }