本文整理匯總了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();
}