tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r585538 - /tomcat/sandbox/gdev6x/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
Date Wed, 17 Oct 2007 15:34:54 GMT
Author: fhanik
Date: Wed Oct 17 08:34:53 2007
New Revision: 585538

URL: http://svn.apache.org/viewvc?rev=585538&view=rev
Log:
http://issues.apache.org/bugzilla/show_bug.cgi?id=43641

Modified:
    tomcat/sandbox/gdev6x/java/org/apache/catalina/tribes/membership/McastServiceImpl.java

Modified: tomcat/sandbox/gdev6x/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/gdev6x/java/org/apache/catalina/tribes/membership/McastServiceImpl.java?rev=585538&r1=585537&r2=585538&view=diff
==============================================================================
--- tomcat/sandbox/gdev6x/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
(original)
+++ tomcat/sandbox/gdev6x/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
Wed Oct 17 08:34:53 2007
@@ -29,6 +29,7 @@
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.MembershipListener;
+import java.net.BindException;
 
 /**
  * A <b>membership</b> implementation using simple multicast.
@@ -182,8 +183,22 @@
     }
     
     protected void setupSocket() throws IOException {
-        if (mcastBindAddress != null) socket = new MulticastSocket(new InetSocketAddress(mcastBindAddress,
port));
-        else socket = new MulticastSocket(port);
+        if (mcastBindAddress != null) {
+            try {
+                log.info("Attempting to bind the multicast socket to "+address+":"+port);
+                socket = new MulticastSocket(new InetSocketAddress(address,port));
+            } catch (BindException e) {
+                /*
+                 * On some plattforms (e.g. Linux) it is not possible to bind
+                 * to the multicast address. In this case only bind to the
+                 * port.
+                 */
+                log.info("Binding to multicast address, failed. Binding to port only.");
+                socket = new MulticastSocket(port);
+            }
+        } else {
+            socket = new MulticastSocket(port);
+        }
         socket.setLoopbackMode(false); //hint that we don't need loop back messages
         if (mcastBindAddress != null) {
 			if(log.isInfoEnabled())



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message