Socket error handling.