コード例 #1
0
ファイル: LibuvConnection.cs プロジェクト: zzl1010/aspnetcore
        public LibuvConnection(UvStreamHandle socket,
                               ILibuvTrace log,
                               LibuvThread thread,
                               IPEndPoint remoteEndPoint,
                               IPEndPoint localEndPoint,
                               PipeOptions inputOptions  = null,
                               PipeOptions outputOptions = null,
                               long?maxReadBufferSize    = null,
                               long?maxWriteBufferSize   = null)
        {
            _socket = socket;

            LocalEndPoint  = localEndPoint;
            RemoteEndPoint = remoteEndPoint;

            ConnectionClosed = _connectionClosedTokenSource.Token;
            Log    = log;
            Thread = thread;

            maxReadBufferSize ??= 0;
            maxWriteBufferSize ??= 0;

            inputOptions ??= new PipeOptions(MemoryPool, PipeScheduler.ThreadPool, Thread, maxReadBufferSize.Value, maxReadBufferSize.Value / 2, useSynchronizationContext: false);
            outputOptions ??= new PipeOptions(MemoryPool, Thread, PipeScheduler.ThreadPool, maxWriteBufferSize.Value, maxWriteBufferSize.Value / 2, useSynchronizationContext: false);

            var pair = DuplexPipe.CreateConnectionPair(inputOptions, outputOptions);

            // Set the transport and connection id
            Transport   = pair.Transport;
            Application = pair.Application;
        }
コード例 #2
0
 public LibuvOutputConsumer(
     PipeReader pipe,
     LibuvThread thread,
     UvStreamHandle socket,
     string connectionId,
     ILibuvTrace log)
 {
     _pipe         = pipe;
     _thread       = thread;
     _socket       = socket;
     _connectionId = connectionId;
     _log          = log;
 }
コード例 #3
0
ファイル: Listener.cs プロジェクト: lingku7080/asp.netcore
        public Task StartAsync(
            EndPoint endPoint,
            LibuvThread thread)
        {
            EndPoint = endPoint;
            Thread   = thread;

            return(Thread.PostAsync(listener =>
            {
                listener.ListenSocket = listener.CreateListenSocket();
                listener.ListenSocket.Listen(LibuvConstants.ListenBacklog, ConnectionCallback, listener);
            }, this));
        }
コード例 #4
0
        public LibuvConnection(UvStreamHandle socket, ILibuvTrace log, LibuvThread thread, IPEndPoint remoteEndPoint, IPEndPoint localEndPoint)
        {
            _socket = socket;

            RemoteAddress = remoteEndPoint?.Address;
            RemotePort    = remoteEndPoint?.Port ?? 0;

            LocalAddress = localEndPoint?.Address;
            LocalPort    = localEndPoint?.Port ?? 0;

            ConnectionClosed = _connectionClosedTokenSource.Token;
            Log    = log;
            Thread = thread;
        }
コード例 #5
0
        public LibuvOutputConsumer(
            IPipeReader pipe,
            LibuvThread thread,
            UvStreamHandle socket,
            string connectionId,
            ILibuvTrace log)
        {
            _pipe         = pipe;
            _thread       = thread;
            _socket       = socket;
            _connectionId = connectionId;
            _log          = log;

            _pipe.OnWriterCompleted(OnWriterCompleted, this);
        }
コード例 #6
0
ファイル: Listener.cs プロジェクト: zzl1010/aspnetcore
        public Task StartAsync(
            EndPoint endPoint,
            LibuvThread thread)
        {
            EndPoint = endPoint;
            Thread   = thread;

            return(Thread.PostAsync(listener =>
            {
                listener.ListenSocket = listener.CreateListenSocket();
#pragma warning disable CS0618
                listener.ListenSocket.Listen(TransportContext.Options.Backlog, ConnectionCallback, listener);
#pragma warning restore CS0618
            }, this));
        }
コード例 #7
0
        public Task StartAsync(
            string pipeName,
            byte[] pipeMessage,
            EndPoint endPoint,
            LibuvThread thread)
        {
            _pipeName    = pipeName;
            _pipeMessage = pipeMessage;
            _buf         = thread.Loop.Libuv.buf_init(_ptr, 4);

            EndPoint     = endPoint;
            Thread       = thread;
            DispatchPipe = new UvPipeHandle(Log);

            var tcs = new TaskCompletionSource <int>(this, TaskCreationOptions.RunContinuationsAsynchronously);

            Thread.Post(StartCallback, tcs);
            return(tcs.Task);
        }
コード例 #8
0
        public LibuvConnection(UvStreamHandle socket, ILibuvTrace log, LibuvThread thread)
        {
            _socket = socket;

            if (_socket is UvTcpHandle tcpHandle)
            {
                var remoteEndPoint = tcpHandle.GetPeerIPEndPoint();
                var localEndPoint  = tcpHandle.GetSockIPEndPoint();

                RemoteAddress = remoteEndPoint.Address;
                RemotePort    = remoteEndPoint.Port;

                LocalAddress = localEndPoint.Address;
                LocalPort    = localEndPoint.Port;
            }

            Log    = log;
            Thread = thread;
        }
コード例 #9
0
        public async Task StartAsync(
            string pipeName,
            byte[] pipeMessage,
            IEndPointInformation endPointInformation,
            LibuvThread thread)
        {
            _pipeName    = pipeName;
            _pipeMessage = pipeMessage;

            if (_fileCompletionInfoPtr == IntPtr.Zero)
            {
                var fileCompletionInfo = new FILE_COMPLETION_INFORMATION {
                    Key = IntPtr.Zero, Port = IntPtr.Zero
                };
                _fileCompletionInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(fileCompletionInfo));
                Marshal.StructureToPtr(fileCompletionInfo, _fileCompletionInfoPtr, false);
            }

            await StartAsync(endPointInformation, thread).ConfigureAwait(false);

            await Thread.PostAsync(listener => listener.PostCallback(), this).ConfigureAwait(false);
        }
コード例 #10
0
ファイル: WriteReqPool.cs プロジェクト: propil5/aspnetcore
 public WriteReqPool(LibuvThread thread, ILibuvTrace log)
 {
     _thread = thread;
     _log    = log;
 }
コード例 #11
0
ファイル: WriteReqPool.cs プロジェクト: wserr/AspNetCore
 public WriteReqPool(LibuvThread thread, ILogger log)
 {
     _thread = thread;
     _log    = log;
 }