public SocketAddress(AddressFamily family, int size) { if (size < MinSize) { throw new ArgumentOutOfRangeException("size"); } InternalSize = size; Buffer = new byte[(size / IntPtr.Size + 2) * IntPtr.Size]; SocketAddressPal.SetAddressFamily(Buffer, family); }
public void IPv6Address_Get_Set(byte[] address, uint scope) { var buffer = new byte[SocketAddressPal.IPv6AddressSize]; SocketAddressPal.SetAddressFamily(buffer, AddressFamily.InterNetworkV6); SocketAddressPal.SetIPv6Address(buffer, address, scope); var actualAddress = new byte[address.Length]; uint actualScope; SocketAddressPal.GetIPv6Address(buffer, actualAddress, out actualScope); for (var i = 0; i < actualAddress.Length; i++) { Assert.Equal(address[i], actualAddress[i]); } Assert.Equal(scope, actualScope); }
internal SocketAddress(AddressFamily addressFamily, ReadOnlySpan <byte> buffer) { Buffer = buffer.ToArray(); InternalSize = Buffer.Length; SocketAddressPal.SetAddressFamily(Buffer, addressFamily); }