bool is_valid_ip(const std::string& ip) { struct in_addr addr4; struct in6_addr addr6; // 嘗試將IP地址解析為IPv4地址 if (inet_pton(AF_INET, ip.c_str(), &addr4) == 1) { return true; } // 嘗試將IP地址解析為IPv6地址 if (inet_pton(AF_INET6, ip.c_str(), &addr6) ...
www.dbjr.com.cn/program/317862q...htm 2025-6-4