Beispiel #1
0
        private unsafe void tcp_bind_windows_extras(UvTcpHandle handle)
        {
            const int SIO_LOOPBACK_FAST_PATH = -1744830448; // IOC_IN | IOC_WS2 | 16;
            const int WSAEOPNOTSUPP          = 10000 + 45;  // (WSABASEERR+45)
            const int SOCKET_ERROR           = -1;

            var socket = IntPtr.Zero;

            Check(_uv_fileno(handle, ref socket));

            // Enable loopback fast-path for lower latency for localhost comms, like HttpPlatformHandler fronting
            // http://blogs.technet.com/b/wincat/archive/2012/12/05/fast-tcp-loopback-performance-and-low-latency-with-windows-server-2012-tcp-loopback-fast-path.aspx
            // https://github.com/libuv/libuv/issues/489
            var  optionValue = 1;
            uint dwBytes     = 0u;

            var result = NativeMethods.WSAIoctl(socket, SIO_LOOPBACK_FAST_PATH, &optionValue, sizeof(int), null, 0, out dwBytes, IntPtr.Zero, IntPtr.Zero);

            if (result == SOCKET_ERROR)
            {
                var errorId = NativeMethods.WSAGetLastError();
                if (errorId == WSAEOPNOTSUPP)
                {
                    // This system is not >= Windows Server 2012, and the call is not supported.
                }
                else
                {
                    Check(errorId);
                }
            }
        }
Beispiel #2
0
 public void tcp_bind(UvTcpHandle handle, ref SockAddr addr, int flags)
 {
     handle.Validate();
     Check(_uv_tcp_bind(handle, ref addr, flags));
     if (Platform.System == OS.Windows)
     {
         tcp_bind_windows_extras(handle);
     }
 }
Beispiel #3
0
        public void Connect(
            UvTcpHandle tcp,
            ref SockAddr address,
            Action <UvConnectRequest, int, Exception, object> callback,
            object state)
        {
            _callback = callback;
            _state    = state;

            Pin();
            _uv.tcp_connect(this, tcp, ref address, _uv_connect_cb);
        }
Beispiel #4
0
 public static extern int uv_tcp_getpeername(UvTcpHandle handle,out SockAddr name,ref int namelen);
Beispiel #5
0
 public static extern int uv_tcp_keepalive(UvTcpHandle handle,int enable,uint delay);
Beispiel #6
0
 public static extern int uv_tcp_nodelay(UvTcpHandle handle,int enable);
Beispiel #7
0
 public static extern int uv_tcp_connect(UvConnectRequest req,UvTcpHandle handle,ref SockAddr addr,uv_connect_cb cb);
Beispiel #8
0
 public static extern int uv_tcp_open(UvTcpHandle handle,IntPtr hSocket);
Beispiel #9
0
 public static extern int uv_tcp_bind(UvTcpHandle handle,ref SockAddr addr,int flags);
Beispiel #10
0
 public static extern int uv_tcp_init(UvLoopHandle loop,UvTcpHandle handle);
Beispiel #11
0
 public void tcp_getpeername(UvTcpHandle handle, out SockAddr addr, ref int namelen)
 {
     handle.Validate();
     Check(_uv_tcp_getpeername(handle, out addr, ref namelen));
 }
Beispiel #12
0
 public void tcp_keepalive(UvTcpHandle handle, bool enable, uint delay)
 {
     handle.Validate();
     Check(_uv_tcp_keepalive(handle, enable ? 1 : 0, delay));
 }
Beispiel #13
0
 public void tcp_nodelay(UvTcpHandle handle, bool enable)
 {
     handle.Validate();
     Check(_uv_tcp_nodelay(handle, enable ? 1 : 0));
 }
Beispiel #14
0
 public void tcp_open(UvTcpHandle handle, IntPtr hSocket)
 {
     handle.Validate();
     Check(_uv_tcp_open(handle, hSocket));
 }
Beispiel #15
0
 public void tcp_connect(UvConnectRequest req, UvTcpHandle handle, ref SockAddr addr, uv_connect_cb connect_cb)
 {
     req.Validate();
     handle.Validate();
     _uv_tcp_connect(req, handle, ref addr, connect_cb);
 }
Beispiel #16
0
 public void tcp_init(UvLoopHandle loop, UvTcpHandle handle)
 {
     loop.Validate();
     handle.Validate();
     Check(_uv_tcp_init(loop, handle));
 }