public InlineSocketsOptionsDefaults( IListenerLogger listenerLogger, IConnectionLogger connectionLogger, INetworkProvider networkProvider) { _configure = options => { #if NETSTANDARD2_0 var memoryPool = Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.KestrelMemoryPool.Create(); #else var socketTransportOptions = new Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportOptions(); var socketTransportOptionsTypeInfo = socketTransportOptions.GetType().GetTypeInfo(); var memoryPoolFactoryProperty = socketTransportOptionsTypeInfo.GetDeclaredProperty("MemoryPoolFactory"); var memoryPoolFactory = memoryPoolFactoryProperty.GetValue(socketTransportOptions) as Func <MemoryPool <byte> >; var memoryPool = memoryPoolFactory.Invoke(); #endif options.MemoryPool = memoryPool; options.CreateListener = CreateListener; options.CreateConnection = CreateConnection; options.CreateSocketPipelines = CreateSocketPipelines; options.WrapTransportPipelines = WrapTransportPipelines; Listener CreateListener() { return(new Listener(listenerLogger, options, networkProvider)); } IConnection CreateConnection(INetworkSocket socket) { return(new Connection(connectionLogger, options, socket)); } (PipeReader input, PipeWriter output) CreateSocketPipelines(IConnection connection, INetworkSocket socket) { var input = new SocketPipeReader(connectionLogger, options, connection, socket); var output = new SocketPipeWriter(connectionLogger, options, connection, socket); return(input, output); } static IDuplexPipe WrapTransportPipelines(IConnection connection, IDuplexPipe transport) { var input = new CancelNotificationPipeReader(transport.Input, connection.CancelPendingRead); return(new DuplexPipe(input, transport.Output)); } }; }
public SocketDuplexPipe(SocketConnection connection) { Input = new SocketPipeReader(connection); Output = new SocketPipeWriter(connection); }