/** * This is used to flush all queued packets to the underlying * socket. If all of the queued packets have been fully written * then this returns true, otherwise this will return false. * * @return true if all queued packets are flushed to the socket */ public synchronized boolean flush() throws IOException { BufferSegment segment = compacter.build(); while(segment != null) { int size = write(segment); if(size < 0) { throw new TransportException("Connection reset"); } if(size == 0) { break; } segment = compacter.build(); } return complete(); }