[CXF-6795] Enable loopback mode for multicast sockets.
This closes #113

Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d7e2821f
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d7e2821f
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d7e2821f

Branch: refs/heads/3.1.x-fixes
Commit: d7e2821f80efe3501dc4e3e0e54c14e8548739d3
Parents: 75a4e81
Author: Nick Birnie <nick.bir...@seebyte.com>
Authored: Mon Feb 22 16:34:36 2016 +0000
Committer: Daniel Kulp <dk...@apache.org>
Committed: Wed Mar 16 10:51:59 2016 -0400

----------------------------------------------------------------------
 .../src/main/java/org/apache/cxf/transport/udp/UDPConduit.java   | 4 ++++
 .../main/java/org/apache/cxf/transport/udp/UDPDestination.java   | 1 +
 .../java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java  | 2 ++
 3 files changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d7e2821f/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPConduit.java
----------------------------------------------------------------------
diff --git 
a/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPConduit.java 
b/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPConduit.java
index 0326bb9..4df1900 100644
--- 
a/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPConduit.java
+++ 
b/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPConduit.java
@@ -243,6 +243,10 @@ public class UDPConduit extends AbstractConduit {
                 socket.setSendBufferSize(this.size());
                 socket.setReceiveBufferSize(64 * 1024);
                 socket.setBroadcast(true);
+                socket.setReuseAddress(true);
+                if (multicast != null) {
+                    ((MulticastSocket)socket).setLoopbackMode(false);
+                }
                 
                 if (multicast == null) {
                     Enumeration<NetworkInterface> interfaces = 
NetworkInterface.getNetworkInterfaces();

http://git-wip-us.apache.org/repos/asf/cxf/blob/d7e2821f/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPDestination.java
----------------------------------------------------------------------
diff --git 
a/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPDestination.java
 
b/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPDestination.java
index 3442ab2..8f8dfd8 100644
--- 
a/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPDestination.java
+++ 
b/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPDestination.java
@@ -172,6 +172,7 @@ public class UDPDestination extends AbstractDestination {
                 socket.setReceiveBufferSize(64 * 1024);
                 socket.setSendBufferSize(64 * 1024);
                 socket.setTimeToLive(1);
+                socket.setLoopbackMode(false);
                 socket.bind(new InetSocketAddress(isa.getPort()));
                 socket.setNetworkInterface(findNetworkInterface());
                 socket.joinGroup(isa.getAddress());

http://git-wip-us.apache.org/repos/asf/cxf/blob/d7e2821f/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
----------------------------------------------------------------------
diff --git 
a/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
 
b/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
index f44217d..3673206 100644
--- 
a/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
+++ 
b/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
@@ -110,6 +110,8 @@ public final class WSDiscoveryClientTest {
                     MulticastSocket s = new 
MulticastSocket(Integer.parseInt(PORT));
                     s.setBroadcast(true);
                     s.setNetworkInterface(findIpv4Interface());
+                    s.setLoopbackMode(false);
+                    s.setReuseAddress(true);
                     s.joinGroup(address);
                     s.setReceiveBufferSize(64 * 1024);
                     s.setSoTimeout(5000);

Reply via email to