/** * Sends a message. If the previous write didn't complete, tries to complete it. If this still doesn't complete, * the message is dropped (needs to be retransmitted, e.g. by UNICAST3 or NAKACK2). * @param buf * @throws Exception */ @Override public void send(ByteBuffer buf) throws Exception { send(buf, true); }
public void send(byte[] data, int offset, int length) throws Exception { if(conn == null) throw new IllegalStateException("connection to server " + remote_addr + " doesn't exist (has start() been called?)"); conn.send(data, offset, length); }
public void send(ByteBuffer data) throws Exception { if(conn == null) throw new IllegalStateException("connection to server " + remote_addr + " doesn't exist (has start() been called?)"); conn.send(data); }
@Override public void send(byte[] buf, int offset, int length) throws Exception { send(ByteBuffer.wrap(buf, offset, length)); }
@Override public void close() throws IOException { send_lock.lock(); try { if(send_buf.remaining() > 0) { // try to flush send buffer if it still has pending data to send try {send();} catch(Throwable e) {} } Util.close(channel, reader); } finally { connected=false; send_lock.unlock(); } }
conn.receive(); if(key.isWritable()) conn.send(); if(key.isAcceptable()) handleAccept(key);
protected void sendLocalAddress(Address local_addr) throws Exception { try { int addr_size=local_addr.serializedSize(); int expected_size=cookie.length + Global.SHORT_SIZE*2 + addr_size; ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(expected_size +2); out.write(cookie, 0, cookie.length); out.writeShort(Version.version); out.writeShort(addr_size); // address size local_addr.writeTo(out); ByteBuffer buf=out.getByteBuffer(); send(buf, false); updateLastAccessed(); } catch(Exception ex) { close(); throw ex; } }
/** * Sends a message. If the previous write didn't complete, tries to complete it. If this still doesn't complete, * the message is dropped (needs to be retransmitted, e.g. by UNICAST3 or NAKACK2). * @param buf * @throws Exception */ @Override public void send(ByteBuffer buf) throws Exception { send(buf, true); }
public void send(byte[] data, int offset, int length) throws Exception { if(conn == null) throw new IllegalStateException("connection to server " + remote_addr + " doesn't exist (has start() been called?)"); conn.send(data, offset, length); }
public void send(ByteBuffer data) throws Exception { if(conn == null) throw new IllegalStateException("connection to server " + remote_addr + " doesn't exist (has start() been called?)"); conn.send(data); }
@Override public void send(byte[] buf, int offset, int length) throws Exception { send(ByteBuffer.wrap(buf, offset, length)); }
@Override public void close() throws IOException { send_lock.lock(); try { if(send_buf.remaining() > 0) { // try to flush send buffer if it still has pending data to send try {send();} catch(Throwable e) {} } Util.close(channel, reader); } finally { connected=false; send_lock.unlock(); } }
conn.receive(); if(key.isWritable()) conn.send(); if(key.isAcceptable()) handleAccept(key);
protected void sendLocalAddress(Address local_addr) throws Exception { try { int addr_size=local_addr.serializedSize(); int expected_size=cookie.length + Global.SHORT_SIZE*2 + addr_size; ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(expected_size +2); out.write(cookie, 0, cookie.length); out.writeShort(Version.version); out.writeShort(addr_size); // address size local_addr.writeTo(out); ByteBuffer buf=out.getByteBuffer(); send(buf, false); updateLastAccessed(); } catch(Exception ex) { close(); throw ex; } }