public int getExitCode() throws NovacomException { int exitCode = 0; if (packetMode) { try { while (true) { int val = packet.readPacket(); if (val < 0) { throw new Exception(); } } } catch (Exception e) { ArrayList<NovacomPacket.OOB> oobList = packet.getOOBList(); for (int i = 0; i < oobList.size(); i++) { NovacomPacket.OOB curr = oobList.get(i); int messageType = curr.getMessageType(); if (messageType == 2) { return curr.getMessagePayload(); } } throw new NovacomException("No return code found in socket stream"); } } return exitCode; }