ISocket.cs 890 B

12345678910111213141516171819202122232425
  1. using System;
  2. using System.Net;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. namespace MediaBrowser.Model.Net
  6. {
  7. /// <summary>
  8. /// Provides a common interface across platforms for UDP sockets used by this SSDP implementation.
  9. /// </summary>
  10. public interface ISocket : IDisposable
  11. {
  12. IPAddress LocalIPAddress { get; }
  13. Task<SocketReceiveResult> ReceiveAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken);
  14. IAsyncResult BeginReceive(byte[] buffer, int offset, int count, AsyncCallback callback);
  15. SocketReceiveResult EndReceive(IAsyncResult result);
  16. /// <summary>
  17. /// Sends a UDP message to a particular end point (uni or multicast).
  18. /// </summary>
  19. Task SendToAsync(byte[] buffer, int offset, int bytes, IPEndPoint endPoint, CancellationToken cancellationToken);
  20. }
  21. }