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

C# Networking.UvLoopHandle类代码示例

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

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



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

示例1: SocketCanListenAndAccept

 public async Task SocketCanListenAndAccept()
 {
     var loop = new UvLoopHandle(_logger);
     loop.Init(_uv);
     var tcp = new UvTcpHandle(_logger);
     tcp.Init(loop);
     var address = ServerAddress.FromUrl("http://localhost:54321/");
     tcp.Bind(address);
     tcp.Listen(10, (stream, status, error, state) =>
     {
         var tcp2 = new UvTcpHandle(_logger);
         tcp2.Init(loop);
         stream.Accept(tcp2);
         tcp2.Dispose();
         stream.Dispose();
     }, null);
     var t = Task.Run(async () =>
     {
         var socket = new Socket(
             AddressFamily.InterNetwork,
             SocketType.Stream,
             ProtocolType.Tcp);
         await Task.Factory.FromAsync(
             socket.BeginConnect,
             socket.EndConnect,
             new IPEndPoint(IPAddress.Loopback, 54321),
             null,
             TaskCreationOptions.None);
         socket.Dispose();
     });
     loop.Run();
     loop.Dispose();
     await t;
 }
开发者ID:Starcounter,项目名称:KestrelHttpServer,代码行数:34,代码来源:NetworkingTests.cs


示例2: Init

 public void Init(UvLoopHandle loop)
 {
     CreateMemory(
         loop.Libuv,
         loop.ThreadId,
         loop.Libuv.req_size(Libuv.RequestType.SHUTDOWN));
 }
开发者ID:njmube,项目名称:KestrelHttpServer,代码行数:7,代码来源:UvShutdownReq.cs


示例3: LoopCanBeInitAndClose

 public async Task LoopCanBeInitAndClose()
 {
     var loop = new UvLoopHandle();
     loop.Init(_uv);
     loop.Run();
     loop.Dispose();
 }
开发者ID:njmube,项目名称:KestrelHttpServer,代码行数:7,代码来源:NetworkingTests.cs


示例4: LoopCanBeInitAndClose

 public void LoopCanBeInitAndClose()
 {
     var loop = new UvLoopHandle(_logger);
     loop.Init(_uv);
     loop.Run();
     loop.Dispose();
 }
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:7,代码来源:NetworkingTests.cs


示例5: KestrelThread

 public KestrelThread(KestrelEngine engine)
 {
     _engine = engine;
     _loop = new UvLoopHandle();
     _post = new UvAsyncHandle();
     _thread = new Thread(ThreadStart);
     QueueCloseHandle = PostCloseHandle;
 }
开发者ID:stevenliujw,项目名称:KestrelHttpServer,代码行数:8,代码来源:KestrelThread.cs


示例6: Init

 public void Init(UvLoopHandle loop)
 {
     var requestSize = loop.Libuv.req_size(Libuv.RequestType.CONNECT);
     CreateMemory(
         loop.Libuv,
         loop.ThreadId,
         requestSize);
 }
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:8,代码来源:UvConnectRequest.cs


示例7: Init

        public void Init(UvLoopHandle loop, Action<Action<IntPtr>, IntPtr> queueCloseHandle)
        {
            CreateHandle(
                loop.Libuv,
                loop.ThreadId,
                loop.Libuv.handle_size(Libuv.HandleType.TCP), queueCloseHandle);

            _uv.tcp_init(loop, this);
        }
开发者ID:rogeralsing,项目名称:KestrelHttpServer,代码行数:9,代码来源:UvTcpHandle.cs


示例8: Init

        public void Init(UvLoopHandle loop, bool ipc)
        {
            CreateMemory(
                loop.Libuv,
                loop.ThreadId, 
                loop.Libuv.handle_size(Libuv.HandleType.NAMED_PIPE));

            _uv.pipe_init(loop, this, ipc);
        }
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:9,代码来源:UvPipeHandle.cs


示例9: Init

 public void Init(UvLoopHandle loop)
 {
     var requestSize = loop.Libuv.req_size(Libuv.RequestType.WRITE);
     var bufferSize = Marshal.SizeOf<Libuv.uv_buf_t>() * BUFFER_COUNT;
     CreateMemory(
         loop.Libuv,
         loop.ThreadId,
         requestSize + bufferSize);
     _bufs = handle + requestSize;
 }
开发者ID:justkao,项目名称:KestrelHttpServer,代码行数:10,代码来源:UvWriteReq.cs


示例10: Init

        public void Init(UvLoopHandle loop, Action callback)
        {
            CreateMemory(
                loop.Libuv, 
                loop.ThreadId, 
                loop.Libuv.handle_size(Libuv.HandleType.ASYNC));

            _callback = callback;
            _uv.async_init(loop, this, _uv_async_cb);
        }
开发者ID:Starcounter,项目名称:KestrelHttpServer,代码行数:10,代码来源:UvAsyncHandle.cs


示例11: SocketCanBeInitAndClose

 public void SocketCanBeInitAndClose()
 {
     var loop = new UvLoopHandle(_logger);
     loop.Init(_uv);
     var tcp = new UvTcpHandle(_logger);
     tcp.Init(loop);
     tcp.Bind("localhost", 0);
     tcp.Dispose();
     loop.Run();
     loop.Dispose();
 }
开发者ID:rogeralsing,项目名称:KestrelHttpServer,代码行数:11,代码来源:NetworkingTests.cs


示例12: SocketCanBeInitAndClose

 public async Task SocketCanBeInitAndClose()
 {
     var loop = new UvLoopHandle();
     loop.Init(_uv);
     var tcp = new UvTcpHandle();
     tcp.Init(loop);
     tcp.Bind(new IPEndPoint(IPAddress.Loopback, 0));
     tcp.Dispose();
     loop.Run();
     loop.Dispose();
 }
开发者ID:njmube,项目名称:KestrelHttpServer,代码行数:11,代码来源:NetworkingTests.cs


示例13: KestrelThread

 public KestrelThread(KestrelEngine engine)
 {
     _engine = engine;
     _appLifetime = engine.AppLifetime;
     _log = engine.Log;
     _threadPool = engine.ThreadPool;
     _loop = new UvLoopHandle(_log);
     _post = new UvAsyncHandle(_log);
     _thread = new Thread(ThreadStart);
     _thread.Name = "KestrelThread - libuv";
     QueueCloseHandle = PostCloseHandle;
 }
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:12,代码来源:KestrelThread.cs


示例14: SocketCanBeInitAndClose

 public void SocketCanBeInitAndClose()
 {
     var loop = new UvLoopHandle(_logger);
     loop.Init(_uv);
     var tcp = new UvTcpHandle(_logger);
     tcp.Init(loop);
     var address = ServerAddress.FromUrl("http://localhost:0/");
     tcp.Bind(address);
     tcp.Dispose();
     loop.Run();
     loop.Dispose();
 }
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:12,代码来源:NetworkingTests.cs


示例15: InitAndCloseServerPipe

        public void InitAndCloseServerPipe()
        {
            var loop = new UvLoopHandle();
            var pipe = new UvPipeHandle();

            loop.Init(_uv);
            pipe.Init(loop, true);
            pipe.Bind(@"\\.\pipe\InitAndCloseServerPipe");
            pipe.Dispose();

            loop.Run();

            pipe.Dispose();
            loop.Dispose();
        }
开发者ID:justkao,项目名称:KestrelHttpServer,代码行数:15,代码来源:MultipleLoopTests.cs


示例16: AsyncCanBeSent

 public async Task AsyncCanBeSent()
 {
     var loop = new UvLoopHandle();
     loop.Init(_uv);
     var trigger = new UvAsyncHandle();
     var called = false;
     trigger.Init(loop, () =>
     {
         called = true;
         trigger.Dispose();
     });
     trigger.Send();
     loop.Run();
     loop.Dispose();
     Assert.True(called);
 }
开发者ID:njmube,项目名称:KestrelHttpServer,代码行数:16,代码来源:NetworkingTests.cs


示例17: async_init

 public void async_init(UvLoopHandle loop, UvAsyncHandle handle, uv_async_cb cb)
 {
     loop.Validate();
     handle.Validate();
     Check(_uv_async_init(loop, handle, cb));
 }
开发者ID:njmube,项目名称:KestrelHttpServer,代码行数:6,代码来源:Libuv.cs


示例18: ServerPipeListenForConnections

        public void ServerPipeListenForConnections()
        {
            var loop = new UvLoopHandle();
            var serverListenPipe = new UvPipeHandle();

            loop.Init(_uv);
            serverListenPipe.Init(loop, false);
            serverListenPipe.Bind(@"\\.\pipe\ServerPipeListenForConnections");
            serverListenPipe.Listen(128, (_1, status, error, _2) =>
            {
                var serverConnectionPipe = new UvPipeHandle();
                serverConnectionPipe.Init(loop, true);
                try
                {
                    serverListenPipe.Accept(serverConnectionPipe);
                }
                catch (Exception)
                {
                    serverConnectionPipe.Dispose();
                    return;
                }

                var writeRequest = new UvWriteReq();
                writeRequest.Init(loop);
                writeRequest.Write(
                    serverConnectionPipe,
                    new ArraySegment<ArraySegment<byte>>(new ArraySegment<byte>[] { new ArraySegment<byte>(new byte[] { 1, 2, 3, 4 }) }),
                    (_3, status2, error2, _4) =>
                    {
                        writeRequest.Dispose();
                        serverConnectionPipe.Dispose();
                        serverListenPipe.Dispose();
                    },
                    null);

            }, null);

            var worker = new Thread(() =>
            {
                var loop2 = new UvLoopHandle();
                var clientConnectionPipe = new UvPipeHandle();
                var connect = new UvConnectRequest();

                loop2.Init(_uv);
                clientConnectionPipe.Init(loop2, true);
                connect.Init(loop2);
                connect.Connect(clientConnectionPipe, @"\\.\pipe\ServerPipeListenForConnections", (_1, status, error, _2) =>
                {
                    var buf = loop2.Libuv.buf_init(Marshal.AllocHGlobal(8192), 8192);

                    connect.Dispose();
                    clientConnectionPipe.ReadStart(
                        (_3, cb, _4) => buf,
                        (_3, status2, error2, _4) =>
                        {
                            if (status2 == 0)
                            {
                                clientConnectionPipe.Dispose();
                            }
                        },
                        null);
                }, null);
                loop2.Run();
                loop2.Dispose();
            });
            worker.Start();
            loop.Run();
            loop.Dispose();
            worker.Join();
        }
开发者ID:justkao,项目名称:KestrelHttpServer,代码行数:70,代码来源:MultipleLoopTests.cs


示例19: SocketCanRead

 public async Task SocketCanRead()
 {
     int bytesRead = 0;
     var loop = new UvLoopHandle();
     loop.Init(_uv);
     var tcp = new UvTcpHandle();
     tcp.Init(loop);
     tcp.Bind(new IPEndPoint(IPAddress.Loopback, 54321));
     tcp.Listen(10, (_, status, error, state) =>
     {
         Console.WriteLine("Connected");
         var tcp2 = new UvTcpHandle();
         tcp2.Init(loop);
         tcp.Accept(tcp2);
         var data = Marshal.AllocCoTaskMem(500);
         tcp2.ReadStart(
             (a, b, c) => _uv.buf_init(data, 500),
             (__, nread, error2, state2) =>
             {
                 bytesRead += nread;
                 if (nread == 0)
                 {
                     tcp2.Dispose();
                 }
             },
             null);
         tcp.Dispose();
     }, null);
     Console.WriteLine("Task.Run");
     var t = Task.Run(async () =>
     {
         var socket = new Socket(
             AddressFamily.InterNetwork,
             SocketType.Stream,
             ProtocolType.Tcp);
         await Task.Factory.FromAsync(
             socket.BeginConnect,
             socket.EndConnect,
             new IPEndPoint(IPAddress.Loopback, 54321),
             null,
             TaskCreationOptions.None);
         await Task.Factory.FromAsync(
             socket.BeginSend,
             socket.EndSend,
             new[] { new ArraySegment<byte>(new byte[] { 1, 2, 3, 4, 5 }) },
             SocketFlags.None,
             null,
             TaskCreationOptions.None);
         socket.Dispose();
     });
     loop.Run();
     loop.Dispose();
     await t;
 }
开发者ID:njmube,项目名称:KestrelHttpServer,代码行数:54,代码来源:NetworkingTests.cs


示例20: SocketCanReadAndWrite

 public async Task SocketCanReadAndWrite()
 {
     int bytesRead = 0;
     var loop = new UvLoopHandle();
     loop.Init(_uv);
     var tcp = new UvTcpHandle();
     tcp.Init(loop);
     tcp.Bind(new IPEndPoint(IPAddress.Loopback, 54321));
     tcp.Listen(10, (_, status, error, state) =>
     {
         Console.WriteLine("Connected");
         var tcp2 = new UvTcpHandle();
         tcp2.Init(loop);
         tcp.Accept(tcp2);
         var data = Marshal.AllocCoTaskMem(500);
         tcp2.ReadStart(
             (a, b, c) => tcp2.Libuv.buf_init(data, 500),
             (__, nread, error2, state2) =>
             {
                 bytesRead += nread;
                 if (nread == 0)
                 {
                     tcp2.Dispose();
                 }
                 else
                 {
                     for (var x = 0; x != 2; ++x)
                     {
                         var req = new UvWriteReq();
                         req.Init(loop);
                         req.Write(
                             tcp2,
                             new ArraySegment<ArraySegment<byte>>(
                                 new[] { new ArraySegment<byte>(new byte[] { 65, 66, 67, 68, 69 }) }
                                 ),
                             (_1, _2, _3, _4) => { },
                             null);
                     }
                 }
             },
             null);
         tcp.Dispose();
     }, null);
     Console.WriteLine("Task.Run");
     var t = Task.Run(async () =>
     {
         var socket = new Socket(
             AddressFamily.InterNetwork,
             SocketType.Stream,
             ProtocolType.Tcp);
         await Task.Factory.FromAsync(
             socket.BeginConnect,
             socket.EndConnect,
             new IPEndPoint(IPAddress.Loopback, 54321),
             null,
             TaskCreationOptions.None);
         await Task.Factory.FromAsync(
             socket.BeginSend,
             socket.EndSend,
             new[] { new ArraySegment<byte>(new byte[] { 1, 2, 3, 4, 5 }) },
             SocketFlags.None,
             null,
             TaskCreationOptions.None);
         socket.Shutdown(SocketShutdown.Send);
         var buffer = new ArraySegment<byte>(new byte[2048]);
         for (; ;)
         {
             var count = await Task.Factory.FromAsync(
                 socket.BeginReceive,
                 socket.EndReceive,
                 new[] { buffer },
                 SocketFlags.None,
                 null,
                 TaskCreationOptions.None);
             Console.WriteLine("count {0} {1}",
                 count,
                 System.Text.Encoding.ASCII.GetString(buffer.Array, 0, count));
             if (count <= 0) break;
         }
         socket.Dispose();
     });
     loop.Run();
     loop.Dispose();
     await t;
 }
开发者ID:njmube,项目名称:KestrelHttpServer,代码行数:85,代码来源:NetworkingTests.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Networking.UvStreamHandle类代码示例发布时间:2022-05-26
下一篇:
C# Routing.RouteData类代码示例发布时间: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