ISocket.cs 1.2 KB

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