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