-
1. Re: binding multicast detector
tom.elrod Jul 14, 2006 2:16 PM (in response to mazz)I am little confused as to exactly which variables are getting set here. The Address and DefaultIP should be multicast IPs (224.x.x.x). Would actually expect an exception to be thrown if are set to 127.0.0.1 (e.g. java.net.SocketException: Not a multicast address).
You can set the BindAddress to 127.0.0.1, but this is just basically to indicate which network interface to use. -
2. Re: binding multicast detector
mazz Jul 14, 2006 2:28 PM (in response to mazz)Sorry, I misspoke. I was thinking one thing and said another.
I meant to say both Address and DefaultIP are set the same (224.16.16.16).
The BIND address is the thing I set to 127.0.0.1 (I also tried 192.168.0.5).Multicast Detector address: /224.16.16.16 Multicast Detector port: 16162 Multicast Detector bind address: /192.168.0.5 Multicast Detector default IP: 224.16.16.16 Multicast Detector default time delay: 5000 Multicast Detector heartbeat time delay: 1000
With this setup, "netstat" is showing the bind address to be 0.0.0.0 - below are some snippets of my netstat output - you can see 16162 has a local address of 0.0.0.0:C:\Documents and Settings\mazz>netstat -a -n -p U Active Connections Proto Local Address Foreign Address UDP 0.0.0.0:445 *:* ... UDP 0.0.0.0:16162 *:*... UDP 0.0.0.0:54925 *:* ... UDP 127.0.0.1:123 *:* UDP 127.0.0.1:1096 *:* ... UDP 192.168.0.3:123 *:* UDP 192.168.0.3:137 *:* UDP 192.168.0.3:138 *:* UDP 192.168.0.3:1900 *:* UDP 192.168.0.5:123 *:* UDP 192.168.0.5:137 *:* ...
-
3. Re: binding multicast detector
tom.elrod Jul 14, 2006 2:39 PM (in response to mazz)Short answer is I don't know why is showing 0.0.0.0. I tried it on my machine and get:
java.exe:5456 UDP GINGER:16162 *:*
You on windows or linux (my test was on windows)? -
4. Re: binding multicast detector
mazz Jul 14, 2006 2:47 PM (in response to mazz)I'm on windows... show the numeric IP:
netstat -n -a
(note the -n) and see what you get. -
5. Re: binding multicast detector
mazz Jul 14, 2006 2:50 PM (in response to mazz)Mine "looks" OK if I don't ask to see the actual IP:
UDP mazzlap:16162
But if I ask to see the actual IP, I see the 0.0.0.0. -
6. Re: binding multicast detector
tom.elrod Jul 14, 2006 3:15 PM (in response to mazz)Mine showing the 0.0.0.0 as well with -n.
The bind address set it used to set the MulticastSocket's interface (http://java.sun.com/j2se/1.4.2/docs/api/java/net/MulticastSocket.html#setInterface(java.net.InetAddress)).
No idea why netstat showing 0.0.0.0 other than being part of the jdk implementation for previous method. -
7. Re: binding multicast detector
mazz Jul 14, 2006 3:29 PM (in response to mazz)Hmmm... I read the Javadocs and I still get confused - Interface vs. NetworkInterface, blah blah.
I'll keep an eye on this for any potential problems - it just doesn't seem right that netstat is showing that I'm bound to 0.0.0.0 (which I assume means all of them).
I guess no one else has ran into problems with this, so I'll take that as a good sign. Soldiering on... -
8. Re: binding multicast detector
tom.elrod Jul 14, 2006 4:05 PM (in response to mazz)I tried with setting the NetworkInterface and am seeing the same thing.
-
9. Re: binding multicast detector
mazz Jul 14, 2006 4:57 PM (in response to mazz)Maybe Bela or someone on his team can shed some light on this - why its happening and the meaning of those API methods (Interface vs. NetworkInterface).
-
10. Re: binding multicast detector
belaban Jul 15, 2006 4:57 AM (in response to mazz)Did you use MulticastSocket.setNetworkInterface()/setInterface() ? Can you post some *short* sample code ?
Note I'm not subscribed to this forum, so you need to send me the code directly -
11. Re: binding multicast detector
tom.elrod Jul 15, 2006 2:12 PM (in response to mazz)Here is a small test class showing the behavior.
public class MulticastSocketTest { public static void main(String[] args) { try { int port = Integer.parseInt(args[0]); InetAddress interfaceAddress = InetAddress.getByName(args[1]); NetworkInterface networkInterface = NetworkInterface.getByInetAddress(interfaceAddress); InetAddress multicastAddress = InetAddress.getByName(args[2]); System.out.println("port = " + port + "\ninterface address = " + interfaceAddress + "\nnetwork interface = " + networkInterface + "\nmulticast address = " + multicastAddress); MulticastSocket socket = new MulticastSocket(port); socket.setInterface(interfaceAddress); socket.setNetworkInterface(networkInterface); socket.joinGroup(multicastAddress); Thread.currentThread().sleep(60000); } catch (Exception e) { e.printStackTrace(); } } }
When I run this and pass the following arguments:
4900 192.168.1.100 224.1.9.1
I see the following doing 'netstat -n -a':
UDP 0.0.0.0:4900 *:* -
12. Re: binding multicast detector
belaban Jul 16, 2006 4:23 AM (in response to mazz)Okay, the following code below works:
package org.jgroups.tests;
import java.net.*;
/**
* @author Bela Ban
* @version $Id$
*/
public class bla
{
public static void main(String[] args)
{
try
{
int port = Integer.parseInt(args[0]);
InetAddress interfaceAddress = InetAddress.getByName(args[1]);
NetworkInterface networkInterface = NetworkInterface.getByInetAddress(interfaceAddress);
InetAddress multicastAddress = InetAddress.getByName(args[2]);
System.out.println("port = " + port + "\ninterface address = " + interfaceAddress +
"\nnetwork interface = " + networkInterface + "\nmulticast address = " + multicastAddress);
SocketAddress saddr;
saddr=new InetSocketAddress(interfaceAddress, port);
MulticastSocket socket = new MulticastSocket(saddr);
socket.setInterface(interfaceAddress);
socket.setNetworkInterface(networkInterface);
socket.joinGroup(multicastAddress);
Thread.sleep(600000);
}
catch (Exception e)
{
e.printStackTrace();
}
}
} -
13. Re: binding multicast detector
mazz Jul 16, 2006 9:04 PM (in response to mazz)That's weird.. so you have to pass the interface address (InetSocketAddress object) to the constructor for it to work, even though you call the setter (setInterface) with the same address?
Sounds like a JDK bug to me :-) -