IAcceptSocket.cs 971 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. namespace MediaBrowser.Model.Net
  5. {
  6. public interface IAcceptSocket : IDisposable
  7. {
  8. bool DualMode { get; }
  9. IpEndPointInfo LocalEndPoint { get; }
  10. IpEndPointInfo RemoteEndPoint { get; }
  11. void Close();
  12. void Shutdown(bool both);
  13. void Listen(int backlog);
  14. void Bind(IpEndPointInfo endpoint);
  15. void Connect(IpEndPointInfo endPoint);
  16. void StartAccept(Action<IAcceptSocket> onAccept, Func<bool> isClosed);
  17. Task SendFile(string path, byte[] preBuffer, byte[] postBuffer, CancellationToken cancellationToken);
  18. }
  19. public class SocketCreateException : Exception
  20. {
  21. public SocketCreateException(string errorCode, Exception originalException)
  22. : base(errorCode, originalException)
  23. {
  24. ErrorCode = errorCode;
  25. }
  26. public string ErrorCode { get; private set; }
  27. }
  28. }