There are generally two formats for storing IP addresses in the IP address database, one is dotted decimal format (192.168.1.1), and the other is digital format (3232235777). In applications, it is often necessary to convert between these two formats.
To solve this problem, I implemented a quick method for converting between the two in the exnet extension package:
Example of use:
So how do you convert a dotted decimal IP address into a number? An IPv4 address has 4 bytes and looks like this:
Each byte represents the range:
General formula: b4<<24 | b3<<16 | b2<<16 | b1 For example, 222.173.108.86 Conversion method: 222<<24 | 173<<16 | 108<<8 | 86 = 3735907414 For example, 1.0.1.1 Conversion method: 1<<24 | 0<<16 | 1<<8 | 1 = 16777473 The implementation in exnet is as follows:
Just flip the logic of converting a numeric value to a string. This is implemented in exnet as follows:
|
<<: When porting your number to another network, operators should first change their service mindset
[[351012]] On November 6, a satellite named "...
UK regulator Ofcom has revealed that so far in 20...
The fifth generation of mobile communication syst...
Recently, the cloud service of GaussDB T, the wor...
edgeNAT has launched a promotional event after th...
[[405743]] We often use the localhost domain name...
The foundation for seamless 5G implementation 5G ...
[[350322]] As the Double 11 shopping festival app...
[[320457]] This article is reproduced from Leipho...
Tencent Cloud's lightweight application serve...
5G opens a new era of the Internet of Everything....
The last time I shared information about Hosteons...
1. Brief description of background technology Reg...
[51CTO.com original article] Speaking of players ...