• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Networking.UvStreamHandle类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.AspNet.Server.Kestrel.Networking.UvStreamHandle的典型用法代码示例。如果您正苦于以下问题:C# UvStreamHandle类的具体用法?C# UvStreamHandle怎么用?C# UvStreamHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UvStreamHandle类属于Microsoft.AspNet.Server.Kestrel.Networking命名空间,在下文中一共展示了UvStreamHandle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Shutdown

 public void Shutdown(UvStreamHandle handle, Action<UvShutdownReq, int, object> callback, object state)
 {
     _callback = callback;
     _state = state;
     _pin = GCHandle.Alloc(this, GCHandleType.Normal);
     _uv.shutdown(this, handle, _uv_shutdown_cb);
 }
开发者ID:njmube,项目名称:KestrelHttpServer,代码行数:7,代码来源:UvShutdownReq.cs


示例2: Shutdown

 public void Shutdown(UvStreamHandle handle, Action<UvShutdownReq, int, object> callback, object state)
 {
     _callback = callback;
     _state = state;
     Pin();
     _uv.shutdown(this, handle, _uv_shutdown_cb);
 }
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:7,代码来源:UvShutdownReq.cs


示例3: SocketOutput

 public SocketOutput(KestrelThread thread, UvStreamHandle socket, long connectionId, IKestrelTrace log)
 {
     _thread = thread;
     _socket = socket;
     _connectionId = connectionId;
     _log = log;
     _callbacksPending = new Queue<CallbackContext>();
 }
开发者ID:rogeralsing,项目名称:KestrelHttpServer,代码行数:8,代码来源:SocketOutput.cs


示例4: Write

        public unsafe void Write(
            UvStreamHandle handle,
            MemoryPoolIterator2 start,
            MemoryPoolIterator2 end,
            int nBuffers,
            Action<UvWriteReq, int, Exception, object> callback,
            object state)
        {
            try
            {
                // add GCHandle to keeps this SafeHandle alive while request processing
                _pins.Add(GCHandle.Alloc(this, GCHandleType.Normal));

                var pBuffers = (Libuv.uv_buf_t*)_bufs;
                if (nBuffers > BUFFER_COUNT)
                {
                    // create and pin buffer array when it's larger than the pre-allocated one
                    var bufArray = new Libuv.uv_buf_t[nBuffers];
                    var gcHandle = GCHandle.Alloc(bufArray, GCHandleType.Pinned);
                    _pins.Add(gcHandle);
                    pBuffers = (Libuv.uv_buf_t*)gcHandle.AddrOfPinnedObject();
                }

                var block = start.Block;
                for (var index = 0; index < nBuffers; index++)
                {
                    var blockStart = block == start.Block ? start.Index : block.Data.Offset;
                    var blockEnd = block == end.Block ? end.Index : block.Data.Offset + block.Data.Count;

                    // create and pin each segment being written
                    pBuffers[index] = Libuv.buf_init(
                        block.Pin() + blockStart,
                        blockEnd - blockStart);

                    block = block.Next;
                }

                _callback = callback;
                _state = state;
                _uv.write(this, handle, pBuffers, nBuffers, _uv_write_cb);
            }
            catch
            {
                _callback = null;
                _state = null;
                Unpin(this);

                var block = start.Block;
                for (var index = 0; index < nBuffers; index++)
                {
                    block.Unpin();
                    block = block.Next;
                }

                throw;
            }
        }
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:57,代码来源:UvWriteReq.cs


示例5: Connection

        public Connection(ListenerContext context, UvStreamHandle socket) : base(context)
        {
            _socket = socket;
            ConnectionControl = this;

            _connectionId = Interlocked.Increment(ref _lastConnectionId);

            _rawSocketInput = new SocketInput(Memory2, ThreadPool);
            _rawSocketOutput = new SocketOutput(Thread, _socket, Memory2, this, _connectionId, Log, ThreadPool, WriteReqPool);
        }
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:10,代码来源:Connection.cs


示例6: Connection

        public Connection(ListenerContext context, UvStreamHandle socket)
            : base(context)
        {
            _socket = socket;
            ConnectionControl = this;

            _connectionId = Interlocked.Increment(ref _lastConnectionId);

            SocketInput = new SocketInput(Memory2);
            SocketOutput = new SocketOutput(Thread, _socket, _connectionId, Log);
            _frame = new Frame(this);
        }
开发者ID:rogeralsing,项目名称:KestrelHttpServer,代码行数:12,代码来源:Connection.cs


示例7: ConnectionCallback

 protected static void ConnectionCallback(UvStreamHandle stream, int status, Exception error, object state)
 {
     var listener = (Listener) state;
     if (error != null)
     {
         listener.Log.LogError("Listener.ConnectionCallback ", error);
     }
     else
     {
         listener.OnConnection(stream, status);
     }
 }
开发者ID:Starcounter,项目名称:KestrelHttpServer,代码行数:12,代码来源:Listener.cs


示例8: Write

        public unsafe void Write(
            UvStreamHandle handle,
            ArraySegment<ArraySegment<byte>> bufs,
            Action<UvWriteReq, int, Exception, object> callback,
            object state)
        {
            try
            {
                // add GCHandle to keeps this SafeHandle alive while request processing
                _pins.Add(GCHandle.Alloc(this, GCHandleType.Normal));

                var pBuffers = (Libuv.uv_buf_t*)_bufs;
                var nBuffers = bufs.Count;
                if (nBuffers > BUFFER_COUNT)
                {
                    // create and pin buffer array when it's larger than the pre-allocated one
                    var bufArray = new Libuv.uv_buf_t[nBuffers];
                    var gcHandle = GCHandle.Alloc(bufArray, GCHandleType.Pinned);
                    _pins.Add(gcHandle);
                    pBuffers = (Libuv.uv_buf_t*)gcHandle.AddrOfPinnedObject();
                }

                for (var index = 0; index != nBuffers; ++index)
                {
                    // create and pin each segment being written
                    var buf = bufs.Array[bufs.Offset + index];

                    var gcHandle = GCHandle.Alloc(buf.Array, GCHandleType.Pinned);
                    _pins.Add(gcHandle);
                    pBuffers[index] = Libuv.buf_init(
                        gcHandle.AddrOfPinnedObject() + buf.Offset,
                        buf.Count);
                }

                _callback = callback;
                _state = state;
                _uv.write(this, handle, pBuffers, nBuffers, _uv_write_cb);
            }
            catch
            {
                _callback = null;
                _state = null;
                Unpin(this);
                throw;
            }
        }
开发者ID:justkao,项目名称:KestrelHttpServer,代码行数:46,代码来源:UvWriteReq.cs


示例9: OnConnection

        /// <summary>
        /// Handles an incoming connection
        /// </summary>
        /// <param name="listenSocket">Socket being used to listen on</param>
        /// <param name="status">Connection status</param>
        protected override void OnConnection(UvStreamHandle listenSocket, int status)
        {
            var acceptSocket = new UvTcpHandle(Log);
            acceptSocket.Init(Thread.Loop, Thread.QueueCloseHandle);

            try
            {
                listenSocket.Accept(acceptSocket);
            }
            catch (UvException ex)
            {
                Log.LogError("TcpListenerPrimary.OnConnection", ex);
                return;
            }

            DispatchConnection(acceptSocket);
        }
开发者ID:rogeralsing,项目名称:KestrelHttpServer,代码行数:22,代码来源:TcpListenerPrimary.cs


示例10: OnConnection

        /// <summary>
        /// Handles an incoming connection
        /// </summary>
        /// <param name="listenSocket">Socket being used to listen on</param>
        /// <param name="status">Connection status</param>
        protected override void OnConnection(UvStreamHandle listenSocket, int status)
        {
            var acceptSocket = new UvPipeHandle(Log);
            acceptSocket.Init(Thread.Loop, false);

            try
            {
                listenSocket.Accept(acceptSocket);
            }
            catch (UvException ex)
            {
                Log.LogError("PipeListener.OnConnection", ex);
                return;
            }

            DispatchConnection(acceptSocket);
        }
开发者ID:Starcounter,项目名称:KestrelHttpServer,代码行数:22,代码来源:PipeListener.cs


示例11: OnListenPipe

        private void OnListenPipe(UvStreamHandle pipe, int status, Exception error, object state)
        {
            if (status < 0)
            {
                return;
            }

            var dispatchPipe = new UvPipeHandle();
            dispatchPipe.Init(Thread.Loop, true);
            try
            {
                pipe.Accept(dispatchPipe);
            }
            catch (Exception)
            {
                dispatchPipe.Dispose();
                return;
            }
            _dispatchPipes.Add(dispatchPipe);
        }
开发者ID:justkao,项目名称:KestrelHttpServer,代码行数:20,代码来源:ListenerPrimary.cs


示例12: OnListenPipe

        private void OnListenPipe(UvStreamHandle pipe, int status, Exception error)
        {
            if (status < 0)
            {
                return;
            }

            var dispatchPipe = new UvPipeHandle(Log);
            dispatchPipe.Init(Thread.Loop, true);

            try
            {
                pipe.Accept(dispatchPipe);
            }
            catch (UvException ex)
            {
                dispatchPipe.Dispose();
                Log.LogError("ListenerPrimary.OnListenPipe", ex);
                return;
            }

            _dispatchPipes.Add(dispatchPipe);
        }
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:23,代码来源:ListenerPrimary.cs


示例13: DispatchConnection

 protected override void DispatchConnection(UvStreamHandle socket)
 {
     var index = _dispatchIndex++ % (_dispatchPipes.Count + 1);
     if (index == _dispatchPipes.Count)
     {
         base.DispatchConnection(socket);
     }
     else
     {
         var dispatchPipe = _dispatchPipes[index];
         var write = new UvWriteReq(Log);
         write.Init(Thread.Loop);
         write.Write2(
             dispatchPipe,
             _dummyMessage,
             socket,
             (write2, status, error, state) => 
             {
                 write2.Dispose();
                 ((UvStreamHandle)state).Dispose();
             },
             socket);
     }
 }
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:24,代码来源:ListenerPrimary.cs


示例14: SocketOutput

        public SocketOutput(
            KestrelThread thread,
            UvStreamHandle socket,
            MemoryPool2 memory,
            Connection connection,
            long connectionId,
            IKestrelTrace log,
            IThreadPool threadPool,
            Queue<UvWriteReq> writeReqPool)
        {
            _thread = thread;
            _socket = socket;
            _connection = connection;
            _connectionId = connectionId;
            _log = log;
            _threadPool = threadPool;
            _tasksPending = new Queue<TaskCompletionSource<object>>(_initialTaskQueues);
            _tasksCompleted = new Queue<TaskCompletionSource<object>>(_initialTaskQueues);
            _writeContextPool = new Queue<WriteContext>(_maxPooledWriteContexts);
            _writeReqPool = writeReqPool;

            _head = memory.Lease();
            _tail = _head;
        }
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:24,代码来源:SocketOutput.cs


示例15: Contextualize

 internal void Contextualize(
     SocketOutput socketOutput,
     UvStreamHandle socket,
     ArraySegment<byte> buffer,
     Action<Exception, object> callback,
     object state)
 {
     _self = socketOutput;
     _socket = socket;
     _buffer = buffer;
     _callback = callback;
     _state = state;
 }
开发者ID:fakedob,项目名称:KestrelHttpServer,代码行数:13,代码来源:SocketOutput.cs


示例16: uv_write2

 unsafe public static extern int uv_write2(UvRequest req, UvStreamHandle handle, uv_buf_t* bufs, int nbufs, UvStreamHandle sendHandle, uv_write_cb cb);
开发者ID:Starcounter,项目名称:KestrelHttpServer,代码行数:1,代码来源:Libuv.cs


示例17: SocketOutput

 public SocketOutput(KestrelThread thread, UvStreamHandle socket)
 {
     _thread = thread;
     _socket = socket;
 }
开发者ID:fakedob,项目名称:KestrelHttpServer,代码行数:5,代码来源:SocketOutput.cs


示例18: uv_shutdown

 public static extern int uv_shutdown(UvShutdownReq req, UvStreamHandle handle, uv_shutdown_cb cb);
开发者ID:Starcounter,项目名称:KestrelHttpServer,代码行数:1,代码来源:Libuv.cs


示例19: UvWrite

 unsafe private int UvWrite(UvRequest req, UvStreamHandle handle, uv_buf_t* bufs, int nbufs, uv_write_cb cb)
 {
     return _onWrite(handle, new ArraySegment<ArraySegment<byte>>(), status => cb(req.InternalGetHandle(), status));
 }
开发者ID:Starcounter,项目名称:KestrelHttpServer,代码行数:4,代码来源:MockLibuv.cs


示例20: Accept

 public void Accept(UvStreamHandle handle)
 {
     _uv.accept(this, handle);
 }
开发者ID:rogeralsing,项目名称:KestrelHttpServer,代码行数:4,代码来源:UvStreamHandle.cs



注:本文中的Microsoft.AspNet.Server.Kestrel.Networking.UvStreamHandle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SignalR.HubConfiguration类代码示例发布时间:2022-05-26
下一篇:
C# Networking.UvLoopHandle类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap