2017-03-02 13:50:09 -07:00
|
|
|
|
using System;
|
2017-03-12 12:27:26 -07:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2017-03-02 13:50:09 -07:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Model.Net
|
|
|
|
|
{
|
|
|
|
|
public interface IAcceptSocket : IDisposable
|
|
|
|
|
{
|
|
|
|
|
bool DualMode { get; }
|
|
|
|
|
IpEndPointInfo LocalEndPoint { get; }
|
|
|
|
|
IpEndPointInfo RemoteEndPoint { get; }
|
|
|
|
|
void Close();
|
|
|
|
|
void Shutdown(bool both);
|
|
|
|
|
void Listen(int backlog);
|
|
|
|
|
void Bind(IpEndPointInfo endpoint);
|
2017-03-02 22:53:21 -07:00
|
|
|
|
void Connect(IpEndPointInfo endPoint);
|
2017-03-02 13:50:09 -07:00
|
|
|
|
void StartAccept(Action<IAcceptSocket> onAccept, Func<bool> isClosed);
|
2017-03-12 12:27:26 -07:00
|
|
|
|
Task SendFile(string path, byte[] preBuffer, byte[] postBuffer, CancellationToken cancellationToken);
|
2017-03-02 13:50:09 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class SocketCreateException : Exception
|
|
|
|
|
{
|
|
|
|
|
public SocketCreateException(string errorCode, Exception originalException)
|
|
|
|
|
: base(errorCode, originalException)
|
|
|
|
|
{
|
|
|
|
|
ErrorCode = errorCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string ErrorCode { get; private set; }
|
|
|
|
|
}
|
|
|
|
|
}
|