diff --git a/PInvoke/Ws2_32/WinSock2.cs b/PInvoke/Ws2_32/WinSock2.cs index 193f1de0..4bebeb69 100644 --- a/PInvoke/Ws2_32/WinSock2.cs +++ b/PInvoke/Ws2_32/WinSock2.cs @@ -1405,11 +1405,11 @@ namespace Vanara.PInvoke private ulong lower; private ulong upper; - /// The IPv6 standard loopback address. - public static readonly IN6_ADDR Loopback = new IN6_ADDR { lower = 0xff_01_00_00_00_00_00_00, upper = 0x00_00_00_00_00_00_00_01 }; + /// The IPv6 standard loopback address (IN6ADDR_LOOPBACK_INIT). + public static readonly IN6_ADDR Loopback = new(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }); - /// The IPv6 standard unspecified address. - public static readonly IN6_ADDR Unspecified = new IN6_ADDR { lower = 0, upper = 0 }; + /// The IPv6 standard unspecified address (IN6ADDR_ANY_INIT). + public static readonly IN6_ADDR Unspecified = new(); /// Initializes a new instance of the struct. /// The IPv6 address as an array of bytes. diff --git a/UnitTests/PInvoke/Ws2_32/Ws2tcpipTests.cs b/UnitTests/PInvoke/Ws2_32/Ws2tcpipTests.cs index ebecb6e9..0447421b 100644 --- a/UnitTests/PInvoke/Ws2_32/Ws2tcpipTests.cs +++ b/UnitTests/PInvoke/Ws2_32/Ws2tcpipTests.cs @@ -20,6 +20,13 @@ namespace Vanara.PInvoke.Tests public static IPAddress localIP4 => Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork); + [Test] + public void ConstTest() + { + Assert.That(new IPAddress(IN6_ADDR.Unspecified).ToString(), Is.EqualTo("::")); + Assert.That(new IPAddress(IN6_ADDR.Loopback).ToString(), Is.EqualTo("::1")); + } + [Test] public void gai_strerrorTest() {