public void AddressFamily_Get_Set_Throws() { var buffer = new byte[1]; Assert.ThrowsAny <Exception>(() => SocketAddressPal.SetAddressFamily(buffer, AddressFamily.InterNetwork)); Assert.ThrowsAny <Exception>(() => SocketAddressPal.GetAddressFamily(buffer)); }
public void AddressFamily_Get_Set(AddressFamily family) { var buffer = new byte[16]; SocketAddressPal.SetAddressFamily(buffer, family); Assert.Equal(family, SocketAddressPal.GetAddressFamily(buffer)); }
internal static unsafe IPEndPoint INetToIPEndPoint(IntPtr pInetAddress) { // MsQuic always uses storage size as if IPv6 was used Span <byte> addressBytes = new Span <byte>((byte *)pInetAddress, Internals.SocketAddress.IPv6AddressSize); return(new Internals.SocketAddress(SocketAddressPal.GetAddressFamily(addressBytes), addressBytes).GetIPEndPoint()); }
internal static unsafe IPEndPoint GetIPEndPointParam(MsQuicApi api, SafeHandle nativeObject, uint param) { // MsQuic always uses storage size as if IPv6 was used uint valueLen = (uint)Internals.SocketAddress.IPv6AddressSize; Span <byte> address = stackalloc byte[Internals.SocketAddress.IPv6AddressSize]; fixed(byte *paddress = &MemoryMarshal.GetReference(address)) { uint status = api.GetParamDelegate(nativeObject, param, ref valueLen, paddress); QuicExceptionHelpers.ThrowIfFailed(status, "GetIPEndPointParam failed."); } address = address.Slice(0, (int)valueLen); return(new Internals.SocketAddress(SocketAddressPal.GetAddressFamily(address), address) .GetIPEndPoint()); }
internal static unsafe IPEndPoint GetIPEndPointParam(MsQuicApi api, MsQuicSafeHandle nativeObject, uint param) { // MsQuic always uses storage size as if IPv6 was used uint valueLen = (uint)Internals.SocketAddress.IPv6AddressSize; Span <byte> address = stackalloc byte[Internals.SocketAddress.IPv6AddressSize]; fixed(byte *paddress = &MemoryMarshal.GetReference(address)) { ThrowIfFailure(api.ApiTable->GetParam( nativeObject.QuicHandle, param, &valueLen, paddress), "GetIPEndPointParam failed."); } address = address.Slice(0, (int)valueLen); return(new Internals.SocketAddress(SocketAddressPal.GetAddressFamily(address), address).GetIPEndPoint()); }