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"); } }