From 221a77409ac213601f8fe989aecb41228493b26a Mon Sep 17 00:00:00 2001 From: norman Date: Mon, 2 Apr 2012 15:25:40 +0200 Subject: [PATCH] Only use the source address to join a multicast group if it was specified. See #216 --- .../netty/channel/socket/nio/NioDatagramChannel.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramChannel.java b/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramChannel.java index ac82ecbee6..1f901debe4 100644 --- a/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramChannel.java @@ -136,7 +136,13 @@ public final class NioDatagramChannel extends AbstractNioChannel implements io.n } try { - MembershipKey key = getJdkChannel().getChannel().join(multicastAddress, networkInterface); + MembershipKey key; + if (source == null) { + key = getJdkChannel().getChannel().join(multicastAddress, networkInterface); + } else { + key = getJdkChannel().getChannel().join(multicastAddress, networkInterface, source); + } + synchronized (this) { if (memberships == null) { memberships = new HashMap>(); @@ -147,7 +153,7 @@ public final class NioDatagramChannel extends AbstractNioChannel implements io.n keys = new ArrayList(); memberships.put(multicastAddress, keys); } - + System.out.println(key); keys.add(key); } } catch (Throwable e) {