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
Part 01 What is “cyberbullying”? "Cyber vi...
[51CTO.com original article] On March 11, 2019, F...
[[348358]] Many friends who use Apple computers o...
[[418602]] The traditional communication business...
Friendhosting has launched an International Teste...
The ubiquitous wireless technology Wi-Fi has beco...
Thanks to the contributions of national policies,...
Let me recommend HostYun, a long-established low-...
Friendhosting has sent out an email about a new n...
In recent years, wireless charging has been widel...
CloudSilk has launched a VPS host in Tokyo, Japan...
10gbiz has launched a new VPS host in the Hong Ko...
VMISS is offering a 30% discount on all VPS hosts...
JuHost has released a regular November promotion,...
On November 16, the Global System for Mobile Comm...