protected synchronized void transmit(SFTPPacket<Request> payload) throws IOException { final int len = payload.available(); out.write((len >>> 24) & 0xff); out.write((len >>> 16) & 0xff); out.write((len >>> 8) & 0xff); out.write(len & 0xff); out.write(payload.array(), payload.rpos(), len); out.flush(); }
@Test public void shouldReadPacket() throws Exception { byte[] bytes = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; dataout.writeInt(10); dataout.write(bytes); dataout.flush(); SFTPPacket<Response> packet = reader.readPacket(); assertEquals(packet.available(), 10); assertTrue("actual=" + Arrays.toString(packet.array()), Arrays.equals(bytes, subArray(packet.array(), 0, 10))); }
public SFTPPacket<Response> readPacket() throws IOException { final int len = getPacketLength(); packet.clear(); packet.ensureCapacity(len); readIntoBuffer(packet.array(), 0, len); packet.wpos(len); return packet; }
protected synchronized void transmit(SFTPPacket<Request> payload) throws IOException { final int len = payload.available(); out.write((len >>> 24) & 0xff); out.write((len >>> 16) & 0xff); out.write((len >>> 8) & 0xff); out.write(len & 0xff); out.write(payload.array(), payload.rpos(), len); out.flush(); }
protected synchronized void transmit(SFTPPacket<Request> payload) throws IOException { final int len = payload.available(); out.write((len >>> 24) & 0xff); out.write((len >>> 16) & 0xff); out.write((len >>> 8) & 0xff); out.write(len & 0xff); out.write(payload.array(), payload.rpos(), len); out.flush(); }
public SFTPPacket<Response> readPacket() throws IOException { final int len = getPacketLength(); packet.clear(); packet.ensureCapacity(len); readIntoBuffer(packet.array(), 0, len); packet.wpos(len); return packet; }
public SFTPPacket<Response> readPacket() throws IOException { final int len = getPacketLength(); packet.clear(); packet.ensureCapacity(len); readIntoBuffer(packet.array(), 0, len); packet.wpos(len); return packet; }