private D readPacket(int packetLength) throws IOException, Buffer.BufferException { byte[] buf = new byte[packetLength]; readFully(buf); return packetFactory.read(buf); }
@Override protected D doRead() throws TransportException { try { int packetLength = readTcpHeader(); return readPacket(packetLength); } catch (TransportException e) { throw e; } catch (IOException | Buffer.BufferException e) { throw new TransportException(e); } }
private void initWithSocket(String remoteHostname) throws IOException { this.socket.setSoTimeout(soTimeout); this.output = new BufferedOutputStream(this.socket.getOutputStream(), INITIAL_BUFFER_SIZE); packetReaderThread = new DirectTcpPacketReader<>(remoteHostname, socket.getInputStream(), handlers.getPacketFactory(), handlers.getReceiver()); packetReaderThread.start(); }
private void initWithSocket(String remoteHostname) throws IOException { this.socket.setSoTimeout(soTimeout); this.output = new BufferedOutputStream(this.socket.getOutputStream(), INITIAL_BUFFER_SIZE); packetReaderThread = new DirectTcpPacketReader<>(remoteHostname, socket.getInputStream(), handlers.getPacketFactory(), handlers.getReceiver()); packetReaderThread.start(); }
@Override protected D doRead() throws TransportException { try { int packetLength = readTcpHeader(); return readPacket(packetLength); } catch (TransportException e) { throw e; } catch (IOException | Buffer.BufferException e) { throw new TransportException(e); } }
private D readPacket(int packetLength) throws IOException, Buffer.BufferException { byte[] buf = new byte[packetLength]; readFully(buf); return packetFactory.read(buf); }
private int readTcpHeader() throws IOException, Buffer.BufferException { byte[] tcpHeader = new byte[4]; readFully(tcpHeader); Buffer.PlainBuffer plainBuffer = new Buffer.PlainBuffer(tcpHeader, Endian.BE); plainBuffer.readByte(); int packetLength = plainBuffer.readUInt24(); return packetLength; }
private int readTcpHeader() throws IOException, Buffer.BufferException { byte[] tcpHeader = new byte[4]; readFully(tcpHeader); Buffer.PlainBuffer plainBuffer = new Buffer.PlainBuffer(tcpHeader, Endian.BE); plainBuffer.readByte(); int packetLength = plainBuffer.readUInt24(); return packetLength; }