In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly describes how to read the pure IP database common component interface QQWry. NET, the text is very detailed, has a certain reference value, interested friends must read!
This is a read pure IP database common component interface, I am through luma's "pure IP database format detailed explanation" to understand the pure IP database data format, and based on a network IPLocation.dll source code adapted from the basis. Why would I want to adapt this component? Because I see this component in use, every time you open the file stream, and the entire interface uses static properties. It is not suitable for multi-threaded concurrent queries in Web environments, and it is not optimal in performance. Having the luma format explained in detail, and the existing IPLocation.dll source code, makes my job incredibly easy. A small error that occurred was also resolved after a debugging. The performance is also greatly improved compared to IPLocation.dll. Although it is only a few hundred lines of code, although there are many similar codes on the Internet, I still contribute this component to open source. Here are some examples of how interfaces are used:
The code is as follows:
QQWry. NET.QQWryLocator qqWry = new QQWry. NET.QQWryLocator("qqwry.dat");//Initialize the database file and obtain the number of IP records, which can be obtained by Count
QQWry. NET.IPLocation ip = qqWry.Query("120.67.217.7"); //Query an IP address
Console.WriteLine("{0} {1} {2}", ip.IP, ip.Country, ip.Local);
The following code compares to IPlocation.dll in terms of performance:
The copy code is as follows:
Stopwatch stopwatch = new Stopwatch();
List ips = new List { "218.5.3.128", "120.67.217.7", "125.78.67.175", "220.250.64.23", "218.5.3.128", "120.67.217.7", "125.78.67.175", "220.250.64.23" };
stopwatch.Start();
for (int i = 0; i
< 100; i++) { foreach (string item in ips) { ip = qqWry.Query(item); // Console.WriteLine("{0} {1} {2}", ip.IP, ip.Country, ip.Local); } } stopwatch.Stop(); Console.WriteLine("QQWryLocator 花了{0} ms", stopwatch.ElapsedMilliseconds); stopwatch.Reset(); stopwatch.Start(); for (int i = 0; i < 100; i++) { foreach (string item in ips) { string s = IPLocation.IPLocation.IPLocate("qqwry.dat", item); // Console.WriteLine(s); } } stopwatch.Stop(); Console.WriteLine("IPLocation 花了{0} ms", stopwatch.ElapsedMilliseconds); 性能比较结果:The above is "how to read the pure IP database common component interface QQWry. NET" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.