Exemple #1
0
        private UvTcpHandle ListenTcp(bool useFileHandle)
        {
            var socket = new UvTcpHandle(Log);

            try
            {
                socket.Init(Thread.Loop, Thread.QueueCloseHandle);
                socket.NoDelay(EndPointInformation.NoDelay);

                if (!useFileHandle)
                {
                    socket.Bind(EndPointInformation.IPEndPoint);

                    // If requested port was "0", replace with assigned dynamic port.
                    EndPointInformation.IPEndPoint = socket.GetSockIPEndPoint();
                }
                else
                {
                    socket.Open((IntPtr)EndPointInformation.FileHandle);
                }
            }
            catch
            {
                socket.Dispose();
                throw;
            }

            return(socket);
        }
Exemple #2
0
        public void Connect(
            UvTcpHandle socket,
            IPEndPoint endpoint,
            Action <UvConnectRequest, int, UvException, object> callback,
            object state)
        {
            _callback = callback;
            _state    = state;

            SockAddr addr;
            var      addressText = endpoint.Address.ToString();

            UvException error1;

            _uv.ip4_addr(addressText, endpoint.Port, out addr, out error1);

            if (error1 != null)
            {
                UvException error2;
                _uv.ip6_addr(addressText, endpoint.Port, out addr, out error2);
                if (error2 != null)
                {
                    throw error1;
                }
            }

            Libuv.tcp_connect(this, socket, ref addr, _uv_connect_cb);
        }
Exemple #3
0
        private UvTcpHandle CreateAcceptSocket()
        {
            var socket = new UvTcpHandle(Log);

            try
            {
                socket.Init(_thread.Loop, _thread.QueueCloseHandle);
                socket.NoDelay(true);
            }
            catch
            {
                socket.Dispose();
                throw;
            }

            return(socket);
        }
Exemple #4
0
        private UvTcpHandle AcceptTcp()
        {
            var socket = new UvTcpHandle(Log);

            try
            {
                socket.Init(Thread.Loop, Thread.QueueCloseHandle);
                socket.NoDelay(EndPointInformation.NoDelay);
            }
            catch
            {
                socket.Dispose();
                throw;
            }

            return(socket);
        }
Exemple #5
0
 public static extern int uv_tcp_getpeername(UvTcpHandle handle,out SockAddr name,ref int namelen);
Exemple #6
0
 public static extern void uv_tcp_connect(UvConnectRequest req,UvTcpHandle handle,ref SockAddr addr,uv_connect_cb cb);
Exemple #7
0
 public static extern int uv_tcp_nodelay(UvTcpHandle handle,int enable);
Exemple #8
0
 public static extern int uv_tcp_open(UvTcpHandle handle,IntPtr hSocket);
Exemple #9
0
 public static extern int uv_tcp_bind(UvTcpHandle handle,ref SockAddr addr,int flags);
Exemple #10
0
 public static extern int uv_tcp_init(UvLoopHandle loop,UvTcpHandle handle);
Exemple #11
0
 public void tcp_getpeername(UvTcpHandle handle, out SockAddr addr, ref int namelen)
 {
     handle.Validate();
     ThrowIfErrored(_uv_tcp_getpeername(handle, out addr, ref namelen));
 }
Exemple #12
0
 public void tcp_nodelay(UvTcpHandle handle, bool enable)
 {
     handle.Validate();
     ThrowIfErrored(_uv_tcp_nodelay(handle, enable ? 1 : 0));
 }
Exemple #13
0
 public void tcp_open(UvTcpHandle handle, IntPtr hSocket)
 {
     handle.Validate();
     ThrowIfErrored(_uv_tcp_open(handle, hSocket));
 }
Exemple #14
0
 public void tcp_connect(UvConnectRequest req, UvTcpHandle handle, ref SockAddr addr, uv_connect_cb cb)
 {
     req.Validate();
     handle.Validate();
     _uv_tcp_connect(req, handle, ref addr, cb);
 }
Exemple #15
0
 public void tcp_bind(UvTcpHandle handle, ref SockAddr addr, int flags)
 {
     handle.Validate();
     ThrowIfErrored(_uv_tcp_bind(handle, ref addr, flags));
 }
Exemple #16
0
 public void tcp_init(UvLoopHandle loop, UvTcpHandle handle)
 {
     loop.Validate();
     handle.Validate();
     ThrowIfErrored(_uv_tcp_init(loop, handle));
 }