[kaffe] Bug Report: multiple sockets can't bind to same multicast address
Everton da Silva Marques
everton@lab.ipaccess.diveo.net.br
Tue Oct 7 10:56:02 2003
--n8g4imXOkfNTN/H1
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
Kaffe (1.1.1 and 1.1.2) does not allow multiple multicast
sockets to bind to the same address/port pair.
I have attached a small test program which shows the issue.
The output from the test program is:
// Correct output:
/usr/local/j2sdk1.4.2_01/bin/java -classpath build mcast.MulticastListener
FIRST multicast socket bound to 224.0.0.9:1234
FIRST multicast socket joined 224.0.0.9 on interface 0.0.0.0
SECOND multicast socket bound to 224.0.0.9:1234
SECOND multicast socket joined 224.0.0.9 on interface 0.0.0.0
// Output under Kaffe 1.1.1 and 1.1.2:
/usr/local/kaffe-1.1.2/bin/java -classpath build mcast.MulticastListener
FIRST multicast socket bound to 224.0.0.9:1234
FIRST multicast socket joined 224.0.0.9 on interface 108.103.35.8
could not create SECOND multicast socket: java.net.BindException: Address already in use
Is this known?
Thanks,
Everton
--n8g4imXOkfNTN/H1
Content-Type: text/x-java; charset=us-ascii
Content-Disposition: attachment; filename="MulticastListener.java"
package mcast;
import java.io.IOException;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.DatagramPacket;
import java.net.MulticastSocket;
import java.net.UnknownHostException;
class MulticastListener {
private static final String mcastAddr = "224.0.0.9";
private static final int mcastPort = 1234;
private static void go() {
//
// Multicast Address
//
InetAddress multicastAddress;
try {
multicastAddress = InetAddress.getByName(mcastAddr);
}
catch (UnknownHostException e) {
System.err.println("could not solve multicast address: " + e);
return;
}
//
// First Socket
//
MulticastSocket firstMcastSock;
try {
firstMcastSock = new MulticastSocket(mcastPort);
}
catch (Exception e) {
System.err.println("could not create FIRST multicast socket: " + e);
return;
}
System.out.println("FIRST multicast socket bound to " + mcastAddr + ":" + mcastPort);
try {
firstMcastSock.joinGroup(multicastAddress);
}
catch (IOException e) {
System.err.println("could not join FIRST socket to multicast group: " + e);
return;
}
try {
System.out.println("FIRST multicast socket joined " + mcastAddr + " on interface " + firstMcastSock.getInterface().getHostName());
}
catch (SocketException e) {
System.err.println("could not get interface for FIRST multicast socket");
}
//
// Second Socket
//
MulticastSocket secondMcastSock;
try {
secondMcastSock = new MulticastSocket(mcastPort);
}
catch (Exception e) {
System.err.println("could not create SECOND multicast socket: " + e);
return;
}
System.out.println("SECOND multicast socket bound to " + mcastAddr + ":" + mcastPort);
try {
secondMcastSock.joinGroup(multicastAddress);
}
catch (IOException e) {
System.err.println("could not join SECOND socket to multicast group: " + e);
return;
}
try {
System.out.println("SECOND multicast socket joined " + mcastAddr + " on interface " + secondMcastSock.getInterface().getHostName());
}
catch (SocketException e) {
System.err.println("could not get interface for SECOND multicast socket");
}
}
public static void main(String args[]) {
go();
}
}
--n8g4imXOkfNTN/H1--