本文整理汇总了C#中Microsoft.AspNet.Server.Kestrel.Networking.UvLoopHandle类的典型用法代码示例。如果您正苦于以下问题:C# UvLoopHandle类的具体用法?C# UvLoopHandle怎么用?C# UvLoopHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UvLoopHandle类属于Microsoft.AspNet.Server.Kestrel.Networking命名空间,在下文中一共展示了UvLoopHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: Init
public void Init(UvLoopHandle loop)
{
CreateMemory(
loop.Libuv,
loop.ThreadId,
loop.Libuv.req_size(Libuv.RequestType.SHUTDOWN));
}
示例3: LoopCanBeInitAndClose
public async Task LoopCanBeInitAndClose()
{
var loop = new UvLoopHandle();
loop.Init(_uv);
loop.Run();
loop.Dispose();
}
示例4: LoopCanBeInitAndClose
public void LoopCanBeInitAndClose()
{
var loop = new UvLoopHandle(_logger);
loop.Init(_uv);
loop.Run();
loop.Dispose();
}
示例5: KestrelThread
public KestrelThread(KestrelEngine engine)
{
_engine = engine;
_loop = new UvLoopHandle();
_post = new UvAsyncHandle();
_thread = new Thread(ThreadStart);
QueueCloseHandle = PostCloseHandle;
}
示例6: Init
public void Init(UvLoopHandle loop)
{
var requestSize = loop.Libuv.req_size(Libuv.RequestType.CONNECT);
CreateMemory(
loop.Libuv,
loop.ThreadId,
requestSize);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}