Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道 C 中是否有一个函数或代码允许从收到的 IP 地址中知道国家代码或名称。谢谢
这可以使用libgeoip来完成。您可以在 test 子目录中找到一个示例。它基本上像这样工作:
GeoIP *gi = GeoIP_open(path_to_database, flags); const char *country_code = GeoIP_country_code_by_addr(gi, "127.0.0.1");