Exemplo n.º 1
0
  public void start() throws Exception {
    if (can_bind_to_mcast_addr) // https://jira.jboss.org/jira/browse/JGRP-836 - prevent cross
      // talking on Linux
      mcast_sock =
          Util.createMulticastSocket(
              getSocketFactory(), Global.MPING_MCAST_SOCK, mcast_addr, mcast_port, log);
    else mcast_sock = getSocketFactory().createMulticastSocket(Global.MPING_MCAST_SOCK, mcast_port);

    mcast_sock.setTimeToLive(ip_ttl);

    if (receive_on_all_interfaces
        || (receive_interfaces != null && !receive_interfaces.isEmpty())) {
      List<NetworkInterface> interfaces;
      if (receive_interfaces != null) interfaces = receive_interfaces;
      else interfaces = Util.getAllAvailableInterfaces();
      bindToInterfaces(interfaces, mcast_sock, mcast_addr);
    } else {
      if (bind_addr != null) mcast_sock.setInterface(bind_addr);
      mcast_sock.joinGroup(mcast_addr);
    }

    // 3b. Create mcast sender socket
    if (send_on_all_interfaces || (send_interfaces != null && !send_interfaces.isEmpty())) {
      List interfaces;
      NetworkInterface intf;
      if (send_interfaces != null) interfaces = send_interfaces;
      else interfaces = Util.getAllAvailableInterfaces();
      mcast_send_sockets = new MulticastSocket[interfaces.size()];
      int index = 0;
      for (Iterator it = interfaces.iterator(); it.hasNext(); ) {
        intf = (NetworkInterface) it.next();
        mcast_send_sockets[index] = new MulticastSocket();
        mcast_send_sockets[index].setNetworkInterface(intf);
        mcast_send_sockets[index].setTimeToLive(ip_ttl);
        index++;
      }
    }

    startReceiver();
    super.start();
  }
Exemplo n.º 2
0
 public void stop() {
   Util.close(mcast_sock);
   mcast_sock = null;
   receiver = null;
   super.stop();
 }
Exemplo n.º 3
0
 public void init() throws Exception {
   super.init();
   if (log.isDebugEnabled())
     log.debug(
         "bind_addr=" + bind_addr + " mcast_addr=" + mcast_addr + ", mcast_port=" + mcast_port);
 }