@Override
    public void deliverRawText(String text) {
        if (!isClosed()) {
            boolean errorDelivering = false;
            boolean allowedToWrite = false;
            try {
                requestWriting();
                allowedToWrite = true;
                // Register that we started sending data on the connection
                writeStarted();
                writer.write(text);
                writer.flush();
                Log.trace("Sending: " + text);
            }
            catch (Exception e) {
                Log.debug("Error delivering raw text" + "\n" + this.toString(), e);
                errorDelivering = true;
            }
            finally {
                // Register that we finished sending data on the connection
                writeFinished();
                if (allowedToWrite) {
                    releaseWriting();
                }
            }
            if (errorDelivering) {
                close();
            }
        }
    }
Returns true if the socket was closed due to a bad health. The socket is considered to
be in a bad state if a thread has been writing for a while and the write operation has
not finished in a long time or when the client has not sent a heartbeat for a long time.
In any of both cases the socket will be closed.

@return true if the socket was closed due to a bad health.
xmppserver/src/main/java/org/jivesoftware/openfire/net/SocketConnection.java