// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Net; using System.Runtime.InteropServices; namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure { internal static class Constants { public const int ListenBacklog = 128; public const int EOF = -4095; public static readonly int? ECONNRESET = GetECONNRESET(); public static readonly int? EADDRINUSE = GetEADDRINUSE(); /// /// The IPEndPoint Kestrel will bind to if nothing else is specified. /// public static readonly IPEndPoint DefaultIPEndPoint = new IPEndPoint(IPAddress.Loopback, 5000); /// /// Prefix of host name used to specify Unix sockets in the configuration. /// public const string UnixPipeHostPrefix = "unix:/"; /// /// Prefix of host name used to specify pipe file descriptor in the configuration. /// public const string PipeDescriptorPrefix = "pipefd:"; /// /// Prefix of host name used to specify socket descriptor in the configuration. /// public const string SocketDescriptorPrefix = "sockfd:"; public const string ServerName = "Kestrel"; private static int? GetECONNRESET() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return -4077; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { return -104; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { return -54; } return null; } private static int? GetEADDRINUSE() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return -4091; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { return -98; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { return -48; } return null; } } }