moved code to host_from_socket function

- moved host_from_socket code from session_check to its own function
- changed behavior to use 'HOSTNAME' string if host_from_socket fails
- added host_from_socket to session_exit_all
ERRORs should go to stderr