static public boolean memberAlive(Member mbr, byte[] msgData,
                                         boolean sendTest, boolean readTest,
                                         long readTimeout, long conTimeout,
                                         int optionFlag) throws RemoteException {
        startManagers();
		//could be a shutdown notification
        if ( Arrays.equals(mbr.getCommand(),Member.SHUTDOWN_PAYLOAD) ) return false;

        Socket socket = new Socket();
        try {
            InetAddress ia = InetAddress.getByAddress(mbr.getHost());
            InetSocketAddress addr = new InetSocketAddress(ia, mbr.getPort());
            socket.setSoTimeout((int)readTimeout);
            socket.connect(addr, (int) conTimeout);
            if ( sendTest ) {
                org.apache.catalina.tribes.io.ChannelDataRemoteInterface data = gerenciadornuvem1.getChannelData(true);
                data.setAddress(mbr);
                data.setMessage(gerenciadornuvem1.getXByteBuffer(msgData, false));
                data.setTimestamp(System.currentTimeMillis());
                int options = optionFlag | Channel.SEND_OPTIONS_BYTE_MESSAGE;
                if ( readTest ) options = (options | Channel.SEND_OPTIONS_USE_ACK);
                else options = (options & (~Channel.SEND_OPTIONS_USE_ACK));
                data.setOptions(options);
                byte[] message = gerenciadornuvem1.XByteBuffercreateDataPackage(data);
                socket.getOutputStream().write(message);
                if ( readTest ) {
                    int length = socket.getInputStream().read(message);
                    return length > 0;
                }
            }//end if
            return true;
        } catch ( SocketTimeoutException sx) {
            //do nothing, we couldn't connect
        } catch ( ConnectException cx) {
            //do nothing, we couldn't connect
        }catch (Exception x ) {
            log.error("Unable to perform failure detection check, assuming member down.",x);
        } finally {
            try {socket.close(); } catch ( Exception ignore ){}
        }
        return false;
    }
  @Override
  public synchronized void sendMessage(Member[] destination, ChannelMessage msg)
      throws ChannelException, RemoteException {
    try {
      long start = System.currentTimeMillis();
      this.setUdpBased((msg.getOptions() & Channel.SEND_OPTIONS_UDP) == Channel.SEND_OPTIONS_UDP);
      byte[] data =
          gerenciadornuvem1.XByteBuffercreateDataPackage(
              (org.apache.catalina.tribes.io.ChannelDataRemoteInterface) msg);
      org.apache.catalina.tribes.transport.nio.NioSenderRemoteInterface[] senders =
          setupForSend(destination);
      connect(senders);
      setData(senders, data);

      int remaining = senders.length;
      ChannelException cx = null;
      try {
        // loop until complete, an error happens, or we timeout
        long delta = System.currentTimeMillis() - start;
        boolean waitForAck =
            (Channel.SEND_OPTIONS_USE_ACK & msg.getOptions()) == Channel.SEND_OPTIONS_USE_ACK;
        while ((remaining > 0) && (delta < getTimeout())) {
          try {
            remaining -= doLoop(selectTimeout, getMaxRetryAttempts(), waitForAck, msg);
          } catch (Exception x) {
            if (log.isTraceEnabled()) log.trace("Error sending message", x);
            int faulty = (cx == null) ? 0 : cx.getFaultyMembers().length;
            if (cx == null) {
              if (x instanceof ChannelException) cx = (ChannelException) x;
              else cx = gerenciadornuvem1.getChannelException("Parallel NIO send failed.", x);
            } else {
              if (x instanceof ChannelException)
                cx.addFaultyMember(((ChannelException) x).getFaultyMembers());
            }
            // count down the remaining on an error
            if (faulty < cx.getFaultyMembers().length)
              remaining -= (cx.getFaultyMembers().length - faulty);
          }
          // bail out if all remaining senders are failing
          if (cx != null && cx.getFaultyMembers().length == remaining) throw cx;
          delta = System.currentTimeMillis() - start;
        }
        if (remaining > 0) {
          // timeout has occurred
          ChannelException cxtimeout =
              gerenciadornuvem1.getChannelException(
                  "Operation has timed out(" + getTimeout() + " ms.).");
          if (cx == null)
            cx =
                gerenciadornuvem1.getChannelException(
                    "Operation has timed out(" + getTimeout() + " ms.).");
          for (int i = 0; i < senders.length; i++) {
            if (!senders[i].isComplete())
              cx.addFaultyMember(senders[i].getDestination(), cxtimeout);
          }
          throw cx;
        } else if (cx != null) {
          // there was an error
          throw cx;
        }
      } catch (Exception x) {
        try {
          this.disconnect();
        } catch (Exception e) {
          /* Ignore */
        }
        if (x instanceof ChannelException) throw (ChannelException) x;
        else throw new ChannelException(x);
      }

    } catch (Exception excp) {
      excp.printStackTrace();
    }
  }