示例#1
0
        static IntPtr GetSocketHandle(TcpHandle handle)
        {
            IntPtr socket = IntPtr.Zero;

            _ = NativeMethods.uv_fileno(handle.Handle, ref socket);
            return(socket);
        }
示例#2
0
        internal static bool GetReuseAddress(TcpHandle tcpHandle)
        {
            IntPtr socketHandle = GetSocketHandle(tcpHandle);

            return(IsWindows
                ? WindowsApi.GetReuseAddress(socketHandle)
                : UnixApi.GetReuseAddress(socketHandle));
        }
        internal static bool GetReuseAddress(TcpHandle tcpHandle)
        {
            IntPtr socketHandle = GetSocketHandle(tcpHandle);

            return(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
                ? WindowsApi.GetReuseAddress(socketHandle)
                : UnixApi.GetReuseAddress(socketHandle));
        }
示例#4
0
        internal static bool GetReusePort(TcpHandle tcpHandle)
        {
            if (IsWindows)
            {
                return(GetReuseAddress(tcpHandle));
            }

            IntPtr socketHandle = GetSocketHandle(tcpHandle);

            return(UnixApi.GetReusePort(socketHandle));
        }
        internal static bool GetReusePort(TcpHandle tcpHandle)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return(GetReuseAddress(tcpHandle));
            }

            IntPtr socketHandle = GetSocketHandle(tcpHandle);

            return(UnixApi.GetReusePort(socketHandle));
        }
示例#6
0
        internal static void SetReusePort(TcpHandle tcpHandle, int value)
        {
            IntPtr socketHandle = GetSocketHandle(tcpHandle);

            // Ignore SO_REUSEPORT on Windows because it is controlled
            // by SO_REUSEADDR
            if (IsWindows)
            {
                return;
            }

            UnixApi.SetReusePort(socketHandle, value);
        }
示例#7
0
        internal static void SetReuseAddress(TcpHandle tcpHandle, int value)
        {
            IntPtr socketHandle = GetSocketHandle(tcpHandle);

            if (IsWindows)
            {
                WindowsApi.SetReuseAddress(socketHandle, value);
            }
            else
            {
                UnixApi.SetReuseAddress(socketHandle, value);
            }
        }
        internal static void SetReusePort(TcpHandle tcpHandle, int value)
        {
            IntPtr socketHandle = GetSocketHandle(tcpHandle);

            // Ignore SO_REUSEPORT on Windows because it is controlled
            // by SO_REUSEADDR
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return;
            }

            UnixApi.SetReusePort(socketHandle, value);
        }
        internal static void SetReuseAddress(TcpHandle tcpHandle, int value)
        {
            IntPtr socketHandle = GetSocketHandle(tcpHandle);

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                WindowsApi.SetReuseAddress(socketHandle, value);
            }
            else
            {
                UnixApi.SetReuseAddress(socketHandle, value);
            }
        }