static IntPtr GetSocketHandle(TcpHandle handle) { IntPtr socket = IntPtr.Zero; _ = NativeMethods.uv_fileno(handle.Handle, ref socket); return(socket); }
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)); }
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)); }
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); }
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); } }