ISocket.cs 950 B

123456789101112131415161718192021222324252627
  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. int Receive(byte[] buffer, int offset, int count);
  15. IAsyncResult BeginReceive(byte[] buffer, int offset, int count, AsyncCallback callback);
  16. SocketReceiveResult EndReceive(IAsyncResult result);
  17. /// <summary>
  18. /// Sends a UDP message to a particular end point (uni or multicast).
  19. /// </summary>
  20. Task SendToAsync(byte[] buffer, int offset, int bytes, IPEndPoint endPoint, CancellationToken cancellationToken);
  21. }
  22. }