Multicast

Jose Orlando Pereira jop at di.uminho.pt
Tue Feb 2 07:14:48 PST 1999


Hi,

MulticastSockets in Kaffe (up to todays snap) differ from JDK in:
 - not setting SO_REUSEADDR by default;
 - not allowing joinGroup with anything other than 224.0.0.0.
The attached patch solves both problems for me (Linux 2.0/glibc2).

-- 
Jose Orlando Pereira
* mailto:jop at di.uminho.pt * http://gsd.di.uminho.pt/~jop *
-------------- next part --------------
diff -ru kaffe-snap/libraries/javalib/java/net/DatagramSocket.java kaffe-snap-jop/libraries/javalib/java/net/DatagramSocket.java
--- kaffe-snap/libraries/javalib/java/net/DatagramSocket.java	Tue Dec  8 02:05:10 1998
+++ kaffe-snap-jop/libraries/javalib/java/net/DatagramSocket.java	Tue Feb  2 15:01:52 1999
@@ -35,6 +35,10 @@
 	}
 	impl = factory.createDatagramSocketImpl();
 	impl.create();
+	init(port, bindAddr);
+}
+
+protected void init(int port, InetAddress bindAddr) throws SocketException {
 	impl.bind(port, bindAddr);
 }
 
diff -ru kaffe-snap/libraries/javalib/java/net/MulticastSocket.java kaffe-snap-jop/libraries/javalib/java/net/MulticastSocket.java
--- kaffe-snap/libraries/javalib/java/net/MulticastSocket.java	Tue Dec  8 02:05:10 1998
+++ kaffe-snap-jop/libraries/javalib/java/net/MulticastSocket.java	Tue Feb  2 15:05:04 1999
@@ -22,8 +22,13 @@
 }
 
 public MulticastSocket(int port) throws IOException {
-	super(port, InetAddress.getByName("224.0.0.0"));
+	super(port, null);
 	iface = InetAddress.getLocalHost();
+}
+
+protected void init(int port, InetAddress bindAddr) throws SocketException {
+	impl.setOption(SocketOptions.SO_REUSEADDR, new Boolean(true));
+	super.init(port, bindAddr);
 }
 
 public InetAddress getInterface() throws SocketException {


More information about the kaffe mailing list