Azure / DotNetty

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

ChannelOption.IpMulticastTtl is ignored #447

Open mockc opened 5 years ago

mockc commented 5 years ago

When attempting to set the IpMulticastTtl channel option the provided value is ignored and instead the default value of 1 is retained.

var multicastHandler = new MulticastTestHandler();
var serverBootstrap = new Bootstrap();
serverBootstrap
    .Group(serverGroup)
    .ChannelFactory(() => new SocketDatagramChannel(addressFamily))
    .Option(ChannelOption.IpMulticastTtl, 128)
    .Handler(new ActionChannelInitializer<IChannel>(channel =>
    {
        channel.Pipeline.AddLast(nameof(SocketDatagramChannelMulticastTest), multicastHandler);
    }));

Also, attempting to get the IpMulticastTtl channel option results in the following exception.

System.InvalidCastException: 'Unable to cast object of type 'System.Int32' to type 'System.Int16'.'

int multicast = serverChannel.Configuration.GetOption(ChannelOption.IpMulticastTtl);

IpMulticastTtl is declared as ChannelOption<int> and possibly should be declared as ChannelOption<short>?

caozhiyuan commented 5 years ago

@nayato @yyjdelete https://github.com/Azure/DotNetty/blob/master/src/DotNetty.Transport/Channels/Sockets/DefaultDatagramChannelConfig.cs#L97