public ConnectRequest(IntPtr handle, IPEndPoint remoteEndPoint) : base(uv_req_type.UV_CONNECT, 0)
        {
            Libuv.GetSocketAddress(remoteEndPoint, out sockaddr addr);
            int result = Libuv.uv_tcp_connect(
                this.Handle,
                handle,
                ref addr,
                WatcherCallback);

            //ThrowIfError(result);
            if (result < 0)
            {
                error = Libuv.CreateError((uv_err_code)result);
                OnWatcherCallback();
            }
        }
Exemple #2
0
        public void Bind(IPEndPoint ip)
        {
            sockaddr addr = new sockaddr();

            Libuv.GetSocketAddress(ip, out addr);

            int r = Libuv.uv_tcp_init(_eventLoop.Loop, _handle);

            if (r != 0)
            {
                Console.WriteLine($"uv_tcp_init error:{r}");
            }

            r = Libuv.uv_tcp_bind(_handle, ref addr, 0);
            if (r != 0)
            {
                Console.WriteLine($"uv_tcp_bind error:{r}");
            }



            //Libuv.uv_run(_loop, Libuv.uv_run_mode.UV_RUN_DEFAULT);
        }