Skip to content

SocketAddress with arbitrary AddressFamily throws PNSE on Unix #29684

@stephentoub

Description

@stephentoub

This succeeds on Windows:

new SocketAddress((AddressFamily)12345).ToString()

returning:

"12345:32:{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}"

but on Linux and macOS it throws:

Unhandled Exception of Type System.PlatformNotSupportedException
Message :
System.PlatformNotSupportedException : Operation is not supported on this platform.
Stack Trace :
   at System.Net.SocketAddressPal.ThrowOnFailure(Error err) in /_/src/Common/src/System/Net/SocketAddressPal.Unix.cs:line 51
   at System.Net.SocketAddressPal.SetAddressFamily(Byte[] buffer, AddressFamily family) in /_/src/Common/src/System/Net/SocketAddressPal.Unix.cs:line 76
   at System.Net.SocketAddress..ctor(AddressFamily family, Int32 size) in /_/src/Common/src/System/Net/SocketAddress.cs:line 96

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions