ISocket.cs 1.0 KB

1234567891011121314151617181920212223242526272829
  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. /// <summary>
  21. /// Sends a UDP message to a particular end point (uni or multicast).
  22. /// </summary>
  23. Task SendAsync(byte[] buffer, int bytes, IpEndPointInfo endPoint, CancellationToken cancellationToken);
  24. Task SendWithLockAsync(byte[] buffer, int bytes, IpEndPointInfo endPoint, CancellationToken cancellationToken);
  25. }
  26. }