Control messages can be sent in the middle of a fragmented message.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk@1453440 13f79535-47bb-0310-9956-ffa450edef68
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54612
Check if socket is closed before trying to write a message to it.
Also, flush any partial buffered data before closing the socket.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk@1453443 13f79535-47bb-0310-9956-ffa450edef68