[EMAIL PROTECTED] wrote:

If you choose one of the interfaces that are bound to "getLocalHost" this
will get the ip's associated with the localhost (in my setup was "laptop")

Correct. Hey, I'm not saying the current solution is elegant. But there are 2 reasons for doing it the way it is done: JDK 1.4 is not (yet) supported and there's a bug in one of the Windows versions which requires bind_addr to be non-null (I forgot what the bug is, and on which version of Windows it appears). Otherwise, the following code would just be commented out:

void createSockets() throws Exception {
InetAddress tmp_addr=null;

// bind_addr not set, try to assign one by default. This is needed on Windows
// @todo: replace this code in JDK 1.4 with java.net.NetworkInterface API
*
// ----- unneeded code -----

if(bind_addr == null) {
InetAddress[] interfaces=InetAddress.getAllByName(InetAddress.getLocalHost().getHostAddress());
if(interfaces != null && interfaces.length > 0)
bind_addr=interfaces[0];
}
if(bind_addr == null)
bind_addr=InetAddress.getLocalHost();


// ----- end of unneeded code -----*


Because if we leave bind_addr null, then we will leave it up to the stack to choose the correct network interface. You may try to comment those lines in your code and see which interface is selected.

I had a eth0 interface enabled by dhcp, provided by my work network.
That dhcp settings would not change my etc/hosts or anything like that.
So, I have a ifconfig showing eth0 and lo, but the code above selects lo
only as it's the only interface bound with "laptop". eth0 matches with a
name like "laptop-xx".

Yes, in the above code, your 'localhost' needs to point to the eth0 interface.


If you use that 1.4 feature that you state, keeping the code above, you'll
get something like this:
"Get all interfaces bound with localhostname"
"Of those, select the first non-lo interface" (in my setup I have none
[eth0 is not bound to hostname but to another name] so it would fall back
to lo again)

No, the algorithm is:
- get *all* interfaces in your box (not just the ones bounds to localhost)
- choose the first non-loopback interface

Once again I ask: Why can't this interface selection be similar to the one
found in McastReceiverTest? (I have not seen the code, but it seems to
select every interface and not only the ones bound to hostname)

You should get the same outcome if you comment the above code. Can you try and let me know the result ? This is especially important if you're on Windows. Maybe that bug has been fixed.


--
Bela Ban
http://www.javagroups.com
Cell: (408) 316-4459



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to