예제 #1
0
 public void close() throws IOException {
   IOException firstExc = null;
   if (is != null) {
     try {
       is.close();
     } catch (IOException e) {
       firstExc = e;
     }
     is = null;
   }
   if (os != null) {
     try {
       os.close();
     } catch (IOException e) {
       firstExc = (firstExc != null ? firstExc : e);
     }
     os = null;
   }
   if (sc != null) {
     try {
       sc.close();
     } catch (IOException e) {
       firstExc = (firstExc != null ? firstExc : e);
     }
     sc = null;
   }
   if (firstExc != null) {
     throw firstExc;
   }
 }
예제 #2
0
 public int writePacket(JICPPacket pkt) throws IOException {
   if (sc != null) {
     if (os == null) {
       os = getOutputStream();
     }
     int ret = pkt.writeTo(os);
     os.flush();
     return ret;
   } else {
     throw new IOException("Connection closed");
   }
 }