handle_socket_error proc and catch flush errors

A flush to a disconnected socket would trace back all the way past the fileevent handler, resulting in the fileevent handler being removed.  Instead we want to close the connection.

New proc handle_socket_error to invoke the eof handler with the posix error code if it can be determined.