ISocket.cs 1.1 KB

123456789101112131415161718192021222324252627282930
  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. Task<SocketReceiveResult> ReceiveAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken);
  16. IAsyncResult BeginReceive(byte[] buffer, int offset, int count, AsyncCallback callback);
  17. SocketReceiveResult EndReceive(IAsyncResult result);
  18. /// <summary>
  19. /// Sends a UDP message to a particular end point (uni or multicast).
  20. /// </summary>
  21. Task SendToAsync(byte[] buffer, int offset, int bytes, IpEndPointInfo endPoint, CancellationToken cancellationToken);
  22. IAsyncResult BeginSendTo(byte[] buffer, int offset, int size, IpEndPointInfo endPoint, AsyncCallback callback, object state);
  23. int EndSendTo(IAsyncResult result);
  24. }
  25. }