5 using System.Net.Sockets;
20 if (IPAddress.IsLoopback(netAddress)) { netAddress = IPAddress.Loopback; }
21 if (netAddress.IsIPv4MappedToIPv6) { netAddress = netAddress.MapToIPv4(); }
27 if (endpointStr.Equals(
"localhost", StringComparison.OrdinalIgnoreCase))
31 else if (IPAddress.TryParse(endpointStr, out IPAddress? netEndpoint))
42 var resolvedAddresses = Dns.GetHostAddresses(endpointStr);
43 return resolvedAddresses.Any()
47 catch (SocketException)
51 catch (ArgumentOutOfRangeException)
57 public override bool Equals(
object? obj)
72 if (IPAddress.IsLoopback(addressA) && IPAddress.IsLoopback(addressB)) {
return true; }
73 return addressA.Equals(addressB);
override int GetHashCode()
override string StringRepresentation
LidgrenAddress(IPAddress netAddress)
override bool Equals(object? obj)
static Option< LidgrenAddress > ParseHostName(string endpointStr)
override bool IsLocalHost
static new Option< LidgrenAddress > Parse(string endpointStr)
readonly IPAddress NetAddress
static bool operator!=(LidgrenAddress a, LidgrenAddress b)
static bool operator==(LidgrenAddress a, LidgrenAddress b)
static Option< T > Some(T value)
static UnspecifiedNone None