ISocket.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.Net;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. namespace MediaBrowser.Model.Net
  7. {
  8. /// <summary>
  9. /// Provides a common interface across platforms for UDP sockets used by this SSDP implementation.
  10. /// </summary>
  11. public interface ISocket : IDisposable
  12. {
  13. IPAddress LocalIPAddress { get; }
  14. Task<SocketReceiveResult> ReceiveAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken);
  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. /// <param name="buffer">An array of type <see cref="byte" /> that contains the data to send.</param>
  21. /// <param name="offset">The zero-based position in buffer at which to begin sending data.</param>
  22. /// <param name="bytes">The number of bytes to send.</param>
  23. /// <param name="endPoint">An <see cref="IPEndPoint" /> that represents the remote device.</param>
  24. /// <param name="cancellationToken">The cancellation token to cancel operation.</param>
  25. /// <returns>The task object representing the asynchronous operation.</returns>
  26. Task SendToAsync(byte[] buffer, int offset, int bytes, IPEndPoint endPoint, CancellationToken cancellationToken);
  27. }
  28. }