private void doWrite(ByteBuffer buff) throws IOException {

        if (buff == null) {
            // Possibly handshaking process
            buff = ByteBuffer.allocate(0);
        }

        if (wrapper == null) {
            writeToSocket(buff);
        } else {
            tlsWrite(buff);
        }
    }
<code>TLSWrapper</code> is a TLS wrapper for connections requiring TLS protocol.
xmppserver/src/main/java/org/jivesoftware/openfire/net/TLSStreamWriter.java