2013年10月7日星期一

Ask: abnormal multicast , IP .0 and .255 are the same with the exception

Code:
try {
group = InetAddress.getByName ("192.168.1.0"); / / 192.168.1.255 also appeared with the same prompt
socket = new MulticastSocket (port);
socket.joinGroup (group);
} catch (Exception e) {
e.printStackTrace ();
}
=====================
native IP: 192.168.1.108, Mask : 255.255.255.0
catch exceptions are:
java.net.SocketException: Not a multicast address
at java.net.MulticastSocket.joinGroup (Unknown Source)
at Receive. (Receive.java: 43)
at Receive.main (Receive.java: 115)

ask you master , the broadcast IP right should be how much ? With 255 and 0 if can receive broadcasts, but that exceptions have been wrong, very strange
------ Solution --------------------- -----------------------
can refer to how to calculate the broadcast address

http://www.360doc.com/content/12/0325/15/90092_197547744.shtml
------ Solution --------------- -----------------------------
I know , multicast is a multicast , and you use a broadcast address, obviously wrong ah

many services: radio (broadcast), multicast (multicast). For broadcast , all hosts in the network receives a copy of the data . For multicast , the message is sent to a multicast address , network knowledge which means that the data is distributed to want to receive multicast address is sent to the data host. Generally speaking , only allowed to broadcast or multicast UDP socket .

reference post http://blog.csdn.net/han_jiang_xue/article/details/7641193
------ Solution -------------- ------------------------------
multicast group address is agreed upon , you will join the 192.168.xx wrong.

sender must take the package sent to a conforming address, such as 239.1.1.10, the recipient must join the multicast group to receive , which is different from the broadcast multicast place

for your reference wiki
------ For reference only ----- ----------------------------------
Thank you very much . See Demo join group mentioned address 224.255.10.0, there is a demo using 230.0.0.1, this is a real LAN IP do ? Or not real IP, LAN can use the 192.168.xx?
------ For reference only -------------------------------------- -
Thank you, I can test 224.0.0.1 multicast , LAN computer is 192.168 segment.
Is not this just the multicast 224.x a convention has nothing to do with the IP , and LAN computer network does not have any relationship ?
------ For reference only -------------------------------------- -


Yes ipv4 multicast addresses in the range : 224.0.0.0 to 239.255.255.255
The quote
I have to say that post, http://blog.csdn.net/han_jiang_xue/article/details/7641193

没有评论:

发表评论