Add handler for both of on_error and on_eof with trace messages.
Change read loop to avoid unexpected on_error calls.
Close socket handles after read finishes (close gh-106).