Azure / DotNetty

DotNetty project – a port of netty, event-driven asynchronous network application framework
Other
4.09k stars 977 forks source link

PlatformNotSupportedException: This platform does not support packet information for dual-mode sockets #426

Open theladyjaye opened 6 years ago

theladyjaye commented 6 years ago

Running on .NET Core (2.1.401) under MacOS (10.13.6) and using a SocketDatagramChannel I get the following error when I am testing an Outbound handler that wraps my byte buffer into a DatagramPacket

Running the same code under Windows 10 and .NET Core (2.1.401) No PlatformNotSupportedException is thrown

var packet = new DatagramPacket(
    message: (IByteBuffer)message,
    recipient: new IPEndPoint(IPAddress.Loopback, port:10000)
);

return context.WriteAndFlushAsync(packet);
Exception: System.PlatformNotSupportedException: This platform does not support packet information for dual-mode sockets.  If packet information is not required, use Socket.Receive.  If packet information is required set Socket.DualMode to false.
   at System.Net.Sockets.SocketPal.CheckDualModeReceiveSupport(Socket socket)
   at System.Net.Sockets.Socket.ReceiveFromAsync(SocketAsyncEventArgs e)
   at DotNetty.Transport.Channels.Sockets.SocketDatagramChannel.ScheduleSocketRead()
   at DotNetty.Transport.Channels.AbstractChannel.AbstractUnsafe.BeginRead()

Is there a way to disable the DualMode flag? I passed my own new Socket(.. udp ..).DualMode = false to a .ChannelFactory(() => new SocketDatagramChannel(socket)) but that didn't seem to do it.

I get that it's a NET Core issue, what I am looking for is a way around that.

theladyjaye commented 6 years ago

NEVERMIND!

Setting:

.ChannelFactory(() => new SocketDataGramChannel(AddressFamily.InterNetwork))

Solves the issue of the IPv4 and IPv6 binding.