hs != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) {
switch (hs) {
-
+
case NEED_UNWRAP:
// Receive handshaking data from peer
peerNetData.flip();
peerNetData.flip();
peerNetData.compact();
break;
-
+
case OK:
// Process incoming handshaking data
break;
-
+
case CLOSED:
engine.closeInbound();
break;
-
+
}
break;
-
+
case NEED_WRAP:
// Empty the local network packet buffer.
myNetData.clear();
-
+
// Generate handshaking data
res = engine.wrap(myAppData, myNetData);
hs = res.getHandshakeStatus();
-
+
// Check status
switch (res.getStatus()) {
case OK:
os.flush();
myNetData.clear();
break;
-
+
case BUFFER_OVERFLOW:
// FIXME: How much larger should the buffer be?
break;
-
+
case CLOSED:
engine.closeOutbound();
break;
-
+
}
break;