| |

VerySource

 Forgot password?
 Register
Search
View: 1205|Reply: 4

String IP to integer ip, how to get it? Is there a ready-made function call? What does integer ip mean?

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-7 08:20:01
| Show all posts |Read mode
String IP to integer ip, how to get it? Is there a ready-made function call? What does integer ip mean?
Reply

Use magic Report

1

Threads

11

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-7 11:48:01
| Show all posts
in_addr_t inet_addr (const char * cp);
Reply

Use magic Report

1

Threads

11

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-7 12:03:01
| Show all posts
The inet_addr () function converts the Internet host address cp from
       numbers-and-dots notation into binary data in network byte order. If
       the input is invalid, INADDR_NONE (usually -1) is returned. This is an
       obsolete interface to inet_aton (), described immediately above; it is
       obsolete because -1 is a valid address (255.255.255.255), and
       inet_aton () provides a cleaner way to indicate error return.

       The inet_ntoa () function converts the Internet host address in given in
       network byte order to a string in standard numbers-and-dots notation.
       The string is returned in a statically allocated buffer, which subse‐
       quent calls will overwrite.
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-7 22:45:02
| Show all posts
inet_addr ()
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-7 23:18:01
| Show all posts
5.1.10 inet_addr ()

Brief description: Convert a dot interval address into an in_addr.


#include <winsock.h>


unsigned long PASCAL FAR inet_addr (const struct FAR * cp);


cp: A string separated by the Internet standard ".".


Notes:

This function interprets the string in the cp parameter. This string uses the Internet "." Interval format to represent a numeric Internet address. The return value can be used as an Internet address. All Internet addresses are returned in network byte order (bytes are arranged from left to right).

Internet addresses with "." Intervals can be expressed in the following ways:

a.b.c.d, a.b.c, a.b, a

When the four parts have a fixed value, each is interpreted as a byte of data, which forms an Internet four-byte address from left to right. Please note that when an Internet address is represented as a 32-bit integer on Intel machines, the above byte is "d.c.b.a". This is because the bytes of Intel processors are arranged from right to left.

Please note: Only Berkeley supports the following expressions, not the rest of the Internet. Considering compatibility with the software, it should be used in accordance with regulations.

For a three-part address, the last part is interpreted as 16-bit data and used as the right-most two bytes of the network address. In this way, the three-part address can easily represent the group B network address, such as "128.net.host".

For a two-part address, the last part is interpreted as 24-bit data and used as the rightmost three bytes of the network address. In this way, the two-part address can easily represent a group C network address, such as "net.host".

For an address with only one part, its value is directly stored in the network address without any byte reorganization.


return value:

If no error occurs, inet_addr () returns an unsigned long integer, which stores the Internet address in the proper byte order. If the string passed in is not a valid Internet address, for example, any of the "a.b.c.d" addresses exceeds 255, then inet_addr () returns INADDR_NONE.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list