various fixes and enhancements

various fixes and enhancements:
* add Erlang socket style controlling_process function
* fix IP address validation when DNS is not working
* validate all options in the caller process to avoid crashing the socket process
* fix socket error handling when the remote end shuts down