Skip to content

Commit

Permalink
example commit to show shyko what was required
Browse files Browse the repository at this point in the history
  • Loading branch information
osheroff committed Apr 20, 2019
1 parent a8e2720 commit 88147d7
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ public byte[] read() throws IOException {

public void write(Command command, int packetNumber) throws IOException {
byte[] body = command.toByteArray();
outputStream.writeInteger(body.length, 3); // packet length
outputStream.writeInteger(packetNumber, 1);
outputStream.write(body, 0, body.length);
ByteArrayOutputStream wtf = new ByteArrayOutputStream();
wtf.writeInteger(body.length, 3); // packet length
wtf.writeInteger(packetNumber, 1);
wtf.write(body, 0, body.length);
// though it has no effect in case of default (underlying) output stream (SocketOutputStream),
// it may be necessary in case of non-default one
outputStream.flush();
wtf.flush();
socket.getOutputStream().write(wtf.toByteArray());
}

public void write(Command command) throws IOException {
Expand Down

0 comments on commit 88147d7

Please sign in to comment.