public void send(Address dest, byte[] data, int offset, int length) throws Exception { if (dest == null) { if (log.isErrorEnabled()) log.error("destination is null"); return; } if (data == null) { log.warn("data is null; discarding packet"); return; } if (!running.get()) { if (log.isDebugEnabled()) log.debug("connection table is not running, discarding message to " + dest); return; } if (dest.equals(local_addr)) { receive(local_addr, data, offset, length); return; } // 1. Try to obtain correct Connection (or create one if not yet existent) TCPConnection conn; conn = mapper.getConnection(dest); // 2. Send the message using that connection if (conn != null) { try { conn.send(data, offset, length); } catch (Exception ex) { mapper.removeConnection(dest); throw ex; } } }