network.clear();
    public int write() throws IOException {        if (initialHandshake) {            log.debug("Don't call write till handshake is done");            return 0;        }        log.debug("Trying to write");        //        if (network.hasRemaining()) {//            return 0;//        }        network.clear();        SSLEngineResult res = engine.wrap(application, network);                log.info("Wrap: " + res);        network.flip();        sendData();        return res.bytesConsumed();    }