Improve socket error reporting