• Post Reply Bookmark Topic Watch Topic
  • New Topic

Multicast Problem  RSS feed

 
Ben Podoll
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know why running the code below I get this output and error:
(equus is the name of my computer by the way)
-----------------------------------------
equus/192.168.1.100
java.net.SocketException: Not a multicast address
-----------------------------------------
import java.net.*;
public class TestMulticast {
public static void main(String[] args) {
try {
int port = 7000;
MulticastSocket multicastSocket = new MulticastSocket(port);
InetAddress inet = InetAddress.getLocalHost();
System.out.println(inet.toString());
multicastSocket.joinGroup(inet);

String temp = "Hi There";
byte[] data = temp.getBytes();
DatagramPacket datagramPacket = new DatagramPacket(data, data.length, inet, port);
multicastSocket.send(datagramPacket);
System.out.println("Sent!");
} catch (Exception e) {
System.err.println(e.toString());
System.exit(0);
}
}
}
 
Ben Podoll
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured it out.
I had a few minor problems, but the major one was following the definition of the Multicast IP range which has to be in:
224.0.0.0 to 239.255.255.255, inclusive. The address 224.0.0.0 is reserved and should not be used.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!