log.debug(res.getHandshakeStatus());
log.debug(res);
	private int unwrapData() throws IOException {        application.clear();                int bytesRead = 0;                while ((bytesRead = channel.read(network)) < 1) {            try {                Thread.sleep(20);            }catch (Exception e) { e.printStackTrace(); }        }     		log.debug("Read from socket: " + bytesRead);					if (bytesRead == -1) {			engine.closeInbound();						if (network.position() == 0 ||					status == SSLEngineResult.Status.BUFFER_UNDERFLOW) {				return -1;			}		}				network.flip();		SSLEngineResult res = null;                while (network.hasRemaining()) {            log.debug("remaining: " + network.remaining());            res = engine.unwrap(network, application);            log.debug(res.getHandshakeStatus());            if (res.getHandshakeStatus() ==                 SSLEngineResult.HandshakeStatus.NEED_TASK) {                    openTask();                }         else if (res.getHandshakeStatus() ==             SSLEngineResult.HandshakeStatus.FINISHED) {             log.debug("Handshake finished");        } else if (res.getStatus() ==             SSLEngineResult.Status.BUFFER_UNDERFLOW) {            log.debug("underflow");            log.debug("remaining: "+network.remaining());        }        }   		if (res.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.FINISHED) {			initialHandshake = false;		}				if (application.position() == 0 && 				res.getStatus() == SSLEngineResult.Status.OK &&				network.hasRemaining()) {			res = engine.unwrap(network, application);			log.info("Unwrapping:\n" + res);					}		status = res.getStatus();		handshakeStatus = res.getHandshakeStatus();		if (status == SSLEngineResult.Status.CLOSED) {			try			{				log.debug("Connection is being closed by peer.");				network.clear();				application.clear();				res = engine.wrap(application, network);			} catch (SSLException e1) {				log.warn("Error during shutdown.\n" + e1.toString());				try {					channel.close();				} catch (IOException e) {						//DO NOTHING 				}			}			network.flip();			sendData();			return -1;		}					network.compact();		application.flip();				if (handshakeStatus == SSLEngineResult.HandshakeStatus.NEED_TASK ||				handshakeStatus == SSLEngineResult.HandshakeStatus.NEED_WRAP ||				handshakeStatus == SSLEngineResult.HandshakeStatus.FINISHED) 		{			log.debug("Redo the handshake()");			handshake();		}				return application.remaining();	}