static void Main(string[] args) { EventLooper looper = new EventLooper(null); looper.Initialize(); Libuv.TTY tty = new Libuv.TTY( null, looper, TTYFileDescription.StandardIn, true, null ); Console.WriteLine(tty.WindowSize); BufferPin pin = null; tty.ReadStart(length => { pin = new BufferPin((uint)length); return(new Libuv.Structs.Buffer(pin.Start, (uint)length)); }, (buffer, length) => { Console.Write(System.Text.Encoding.UTF8.GetString(pin.Buffer)); }); looper.Run(); }
public WriteRequest(ILibuvLogger logger, EventLooper looper) : base(logger) { this.AllocateMemory( looper.ThreadId, Request.NativeMethods.uv_req_size(RequestType.WRITE) ); this._buffersPointer = IntPtr.Zero; this._writeBuffers = new List <BufferPin>(); }
static void Main(string[] args) { EventLooper looper = new EventLooper(null); looper.Initialize(); Libuv.Tcp server = new Libuv.Tcp(null, looper, null); server.Bind("127.0.0.1", 8000, 0); server.Listen(128, () => { Libuv.Tcp client = server.Accept(looper, null); BufferPin pin = null; client.ReadStart(length => { pin = new BufferPin((uint)length); return(new Libuv.Structs.Buffer(pin.Start, (uint)length)); }, (buffer, length) => { Console.Write(System.Text.Encoding.UTF8.GetString(pin.Buffer, 0, length)); client.ReadStop(); WriteRequest writor = new WriteRequest(null, looper); writor.Write( client, new ArraySegment <ArraySegment <byte> >( new [] { new ArraySegment <byte>(System.Text.Encoding.UTF8.GetBytes("HTTP/1.1 200 OK\r\n")), new ArraySegment <byte>(System.Text.Encoding.UTF8.GetBytes("Content-Length:11\r\nContent-Type:text/html\r\n")), new ArraySegment <byte>(System.Text.Encoding.UTF8.GetBytes("\r\n")), new ArraySegment <byte>(System.Text.Encoding.UTF8.GetBytes("Hello World")) } ), () => { client.Close(); } ); }); }); looper.Run(); }
static void Main(string[] args) { EventLooper looper = new EventLooper(null); FileSystemEvent fsEvent = new FileSystemEvent( null, looper, null ); fsEvent.Start( @"F:\", FileSystemEventFlags.WatchEntry, (name, eventType) => { Console.WriteLine(name); Console.WriteLine(eventType); } ); looper.Run(); }
public ConnectRequest(ILibuvLogger logger, EventLooper looper) : base(logger) { int requestSize = Request.NativeMethods.uv_req_size(RequestType.CONNECT); this.AllocateMemory(looper.ThreadId, requestSize); }