C language Inet_ntoa () function: Converts the number of network binaries into network addresses
header file:
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h>
To define a function:
char * INET_NTOA (struct in_addr in);
Function Description: Inet_ntoa () is used to convert the number of network binary digits in the parameter in to the network address, and then returns a pointer to this network address string.
Return value: Returns a string pointer to success and returns NULL if it fails.
C language Inet_aton () function: To convert the network address into a network binary number
header file:
#include <sys/scoket.h> #include <netinet/in.h> #include <arpa/inet.h>
To define a function:
int Inet_aton (const char * cp, struct in_addr *INP);
Function Description: Inet_aton () is used to convert the network address string referred to in the parameter CP to a binary number used by the network, and then to be stored in the IN_ADDR structure referred to in the parameter INP.
The structure in_addr is defined as follows
struct in_addr
{
unsigned long int s_addr;
};
Return value: Success returns a non 0 value, and a failure returns 0.
C language inet_addr () function: The number that converts the network address into binary
header file:
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h>
To define a function:
unsigned long int inet_addr (const char *CP);
Function Description: inet_addr () is used to convert the network address string that the parameter CP refers to into the binary digits used by the network. A network address string is a string of numbers and dots, for example: "163. 13.132. 68 ".
Return value: Success returns the number of the corresponding network binary, failure returns-1.