protected final void send(Op op, String text) throws IOException { ByteArrayOutputStream buf = new ByteArrayOutputStream(); new DataOutputStream(buf).writeUTF(text); send(op, buf.toByteArray()); }
protected final synchronized void send(Op op, int number) throws IOException { dos.writeInt(4); writeOp(op); dos.writeInt(number); dos.flush(); }
framelen = dis.readInt(); } catch (EOFException x) { handleClose(); break; // TODO verify that we hit EOF immediately, not partway into framelen long start = cis.getByteCount(); LOGGER.log(Level.FINEST, "handling frame with {0} of length {1}", new Object[] {op, framelen}); boolean handled = handle(op, framelen); if (handled) { long actuallyRead = cis.getByteCount() - start; handleClose(); } catch (IOException x) { LOGGER.log(Level.WARNING, null, flightRecorder.analyzeCrash(x, "broken stream")); handleClose(); } catch (RuntimeException x) { LOGGER.log(Level.WARNING, null, x); handleClose();
protected final void send(Op op, byte[] chunk) throws IOException { send(op, chunk, 0, chunk.length); }
@Override public void write(byte[] b) throws IOException { send(op, b); } };
protected final synchronized void send(Op op, byte[] chunk, int off, int len) throws IOException { dos.writeInt(len); writeOp(op); dos.write(chunk, off, len); dos.flush(); }
protected final synchronized void send(Op op) throws IOException { dos.writeInt(0); writeOp(op); dos.flush(); }
@Override public void write(byte[] b, int off, int len) throws IOException { send(op, b, off, len); } @Override
@Override public void write(int b) throws IOException { send(op, new byte[] {(byte) b}); } @Override