示例#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);
                }
            }
        }
示例#2
0
 public void tcp_bind(UvTcpHandle handle, ref SockAddr addr, int flags)
 {
     handle.Validate();
     Check(_uv_tcp_bind(handle, ref addr, flags));
     if (PlatformApis.IsWindows)
     {
         tcp_bind_windows_extras(handle);
     }
 }
示例#3
0
 public static extern int uv_tcp_getpeername(UvTcpHandle handle,out SockAddr name,ref int namelen);
示例#4
0
 public static extern int uv_tcp_nodelay(UvTcpHandle handle,int enable);
示例#5
0
 public static extern int uv_tcp_open(UvTcpHandle handle,IntPtr hSocket);
示例#6
0
 public static extern int uv_tcp_bind(UvTcpHandle handle,ref SockAddr addr,int flags);
示例#7
0
 public static extern int uv_tcp_init(UvLoopHandle loop,UvTcpHandle handle);
示例#8
0
 public void tcp_getpeername(UvTcpHandle handle, out SockAddr addr, ref int namelen)
 {
     handle.Validate();
     ThrowIfErrored(_uv_tcp_getpeername(handle, out addr, ref namelen));
 }
示例#9
0
 public void tcp_nodelay(UvTcpHandle handle, bool enable)
 {
     handle.Validate();
     ThrowIfErrored(_uv_tcp_nodelay(handle, enable ? 1 : 0));
 }
示例#10
0
 public void tcp_open(UvTcpHandle handle, IntPtr hSocket)
 {
     handle.Validate();
     ThrowIfErrored(_uv_tcp_open(handle, hSocket));
 }
示例#11
0
 public void tcp_bind(UvTcpHandle handle, ref SockAddr addr, int flags)
 {
     handle.Validate();
     ThrowIfErrored(_uv_tcp_bind(handle, ref addr, flags));
 }
示例#12
0
 public void tcp_init(UvLoopHandle loop, UvTcpHandle handle)
 {
     loop.Validate();
     handle.Validate();
     ThrowIfErrored(_uv_tcp_init(loop, handle));
 }
示例#13
0
 public void tcp_getsockname(UvTcpHandle handle, out SockAddr addr, ref int namelen)
 {
     handle.Validate();
     Check(_uv_tcp_getsockname(handle, out addr, ref namelen));
 }
示例#14
0
 public void tcp_nodelay(UvTcpHandle handle, bool enable)
 {
     handle.Validate();
     Check(_uv_tcp_nodelay(handle, enable ? 1 : 0));
 }
示例#15
0
 public void tcp_open(UvTcpHandle handle, IntPtr hSocket)
 {
     handle.Validate();
     Check(_uv_tcp_open(handle, hSocket));
 }
示例#16
0
 public void tcp_init(UvLoopHandle loop, UvTcpHandle handle)
 {
     loop.Validate();
     handle.Validate();
     Check(_uv_tcp_init(loop, handle));
 }