Esempio n. 1
0
 public void write(String text) throws IOException {
   if (!packetMode) {
     output.write(text.getBytes("US-ASCII"));
   } else {
     packet.write(text.getBytes("US-ASCII"));
   }
 }
Esempio n. 2
0
 public void write(byte[] data, int offset, int length) throws IOException {
   if (!packetMode) {
     output.write(data, offset, length);
   } else {
     packet.write(data, offset, length);
   }
 }
Esempio n. 3
0
 public void closeInputOutput() throws IOException {
   if (packetMode) {
     output.flush();
     try {
       packet.writeOOBClose(1);
     } catch (IOException e) {
     }
     try {
       packet.writeOOBClose(2);
     } catch (IOException e) {
     }
     try {
       packet.writeOOBClose(0);
     } catch (IOException e) {
     }
     output.flush();
   }
 }
Esempio n. 4
0
 public int read(byte[] buffer) throws IOException {
   int result;
   if (!packetMode) {
     result = input.read(buffer);
   } else {
     result = packet.read(buffer);
   }
   return result;
 }
Esempio n. 5
0
 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;
 }