Qqwry. Net, a public component used to read pure IP Databases

Source: Internet
Author: User

This is a public Component Interface for reading Pure IP database. I learned about the pure IP database data format through Luma's "Pure IP database format details, and based on an iplocation on the network. the DLL source code is adapted. Why should I adapt this component? Because I see that the file stream is opened every time this component is used, and the entire interface uses static attributes. It is not suitable for multi-threaded concurrent queries in the web environment and is not optimal in performance. With the luma format explanation and the source code of the existing iplocation. dll, my work becomes abnormal and simple. A small error is solved after a debugging. Better performance than iplocation. DLL is also greatly improved, although there are only a few hundred lines of Code , although there are many similar code on the internet, however, I still contribute this component to the open source by following my consistent practices. The following is an introduction to some interfaces:

Qqwry. net.QqwrylocatorQqwry =NewQqwry. net.Qqwrylocator("Qqwry. dat");// Initialize the database file and obtain the number of IP records, which can be obtained through countQqwry. net.IplocationIP = qqwry. Query ("120.67.217.7");// Query an IP addressConsole. Writeline ("{0} {1} {2 }", IP. IP, IP. Country, IP. Local );
 
The following is the performance comparison code with iplocation. dll:
  1:  stopwatch =  New  stopwatch (); 
  2:  List  string  IPS =  New  List  string  >{< span style =" color: #006080 ">" 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 "}; 
3:Stopwatch. Start ();
 
4: For(IntI = 0; I <100; I ++)
5:{
 
6:Foreach(StringItemInIPS)
7:{
 
8:IP = qqwry. Query (item );
9:// Console. writeline ("{0} {1} {2}", IP. IP, IP. Country, IP. Local );
 
10:}
11:}
 
12:
13:Stopwatch. Stop ();
 
14:Console. writeline ("Qqwrylocator took {0} ms", Stopwatch. elapsedmilliseconds );
15:
 
16:Stopwatch. Reset ();
17:Stopwatch. Start ();
 
18: For(IntI = 0; I <100; I ++)
19:{
 
20:Foreach(StringItemInIPS)
21:{
 
22:StringS = iplocation. iplocation. iplocate ("Qqwry. dat", Item );
23:// Console. writeline (s );
 
24:}
25:}
 
26:Stopwatch. Stop ();
27:Console. writeline ("Iplocation spent {0} ms", Stopwatch. elapsedmilliseconds );

Performance Comparison results:

 

Download the source code and sample code.

A bu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.