Multicast problem :(

T

tricky

Hi all,

I have a question. I need to create multicast socket but on more then
one interface. I try to do this but unfortunetly it is setup only on one
interface ?
Do a need different ip (group ) per each interface or maybe port or maybe
it's impossible ?

port and ip is the same per each interface
During iterations setInterface() is invoked

public void setInterface(NetworkInterface i){
try {
logger.info("MulticastAnnouncer");

this.address = InetAddress.getByName(defaultIP);
this.socket = new MulticastSocket(port);
this.socket.setNetworkInterface(i);
this.socket.joinGroup(this.address);
 
T

tricky

Esmond Pitt said:

Unfortunetly it doesn't work :( only default interface is used


private static final String defaultIP = "239.0.2.10"; <-this is changed
depended on interface number

public void setInterface(NetworkInterface i){
try {
logger.info("MulticastAnnounce setting interface");

this.address = InetAddress.getByName(defaultIP);
this.socket = new MulticastSocket(port);
this.socket.setNetworkInterface(i);
this.socket.joinGroup(this.address);

logger.info("MulticastSocket Annoucer success");

this.socket = socket;

}catch(Exception e){
logger.error("Cannot set network Interface:"+e.toString());

}
 
E

Esmond Pitt

setInterface() is really only useful for outbound traffic. You need to
use the version of join() where you specify the NetworkInterface, in a
loop, so that you join the group via all available NICs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top