Exemplo n.º 1
0
        public static int try_write(UVStreamHandle handle, uv_buf_t[] bufs, int nbufs)
        {
            handle.Validate();
            var count = uv_try_write(handle, bufs, nbufs);

            ThrowIfErrored(count);
            return(count);
        }
Exemplo n.º 2
0
        private unsafe static void UVReadCb(IntPtr handle, int nread, ref UVIntrop.uv_buf_t buf)
        {
            UVException ex;

            UVIntrop.Check(nread, out ex);

            UVStreamHandle target = FromIntPtr <UVStreamHandle>(handle);

            if (target == null)
            {
                throw new UVException("流已释放");
            }
            target.mReadCallback(target, nread, ex, ref buf, target.mReadCallbackState);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 写入数据
 /// </summary>
 /// <param name="request"></param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 internal unsafe void Write(UVStreamHandle server, Action <UVWriteRequest, Int32, UVException, object> callback, object state)
 {
     try
     {
         this.mWriteCallback      = callback;
         this.mWriteCallbackState = state;
         UVIntrop.write(this, server, this.mBuffer, this.mOffset, mOnWrite);
     }
     catch
     {
         this.UnpinGCHandles();
         throw;
     }
 }
Exemplo n.º 4
0
        private static void UVAllocCb(IntPtr handle, int suggestedSize, out UVIntrop.uv_buf_t buf)
        {
            UVStreamHandle target = FromIntPtr <UVStreamHandle>(handle);

            if (target == null)
            {
                throw new UVException("流已释放");
            }
            try
            {
                buf = target.mAllocCallback(target, suggestedSize, target.mAllocCallbackState);
            }
            catch (Exception ex)
            {
                //todo:清理操作
                throw new UVException("分配内存出错," + ex.Message);
            }
        }
Exemplo n.º 5
0
 unsafe public static extern int uv_write2(UVWriteRequest req, UVStreamHandle handle, uv_buf_t *bufs, int nbufs, UVStreamHandle sendHandle, uv_write_cb cb);
Exemplo n.º 6
0
 public static extern int uv_try_write(UVStreamHandle handle, uv_buf_t[] bufs, int nbufs);
Exemplo n.º 7
0
 public static extern int uv_read_stop(UVStreamHandle handle);
Exemplo n.º 8
0
 public extern static int uv_read_start(UVStreamHandle handle, uv_alloc_cb alloc_cb, uv_read_cb read_cb);
Exemplo n.º 9
0
 public static extern int uv_accept(UVStreamHandle server, UVStreamHandle client);
Exemplo n.º 10
0
 public static extern int uv_listen(UVStreamHandle handle, int backlog, uv_connection_cb cb);
Exemplo n.º 11
0
 public unsafe static void write2(UVWriteRequest req, UVStreamHandle handle, uv_buf_t *bufs, int nbufs, UVStreamHandle sendHandle, uv_write_cb cb)
 {
     req.Validate();
     handle.Validate();
     ThrowIfErrored(uv_write2(req, handle, bufs, nbufs, sendHandle, cb));
 }
Exemplo n.º 12
0
 public static void read_stop(UVStreamHandle handle)
 {
     handle.Validate();
     ThrowIfErrored(uv_read_stop(handle));
 }
Exemplo n.º 13
0
 public static void read_start(UVStreamHandle handle, uv_alloc_cb alloc_cb, uv_read_cb read_cb)
 {
     handle.Validate();
     ThrowIfErrored(uv_read_start(handle, alloc_cb, read_cb));
 }
Exemplo n.º 14
0
 public static void accept(UVStreamHandle server, UVStreamHandle client)
 {
     server.Validate();
     client.Validate();
     ThrowIfErrored(uv_accept(server, client));
 }
Exemplo n.º 15
0
 public static void listen(UVStreamHandle handle, int backlog, uv_connection_cb cb)
 {
     handle.Validate();
     ThrowIfErrored(uv_listen(handle, backlog, cb));
 }