Improved code quality for check_socket_type