What ever :inet_aton function translate ip address presentation such as “192.168.0.1” to numeric number in host.That is to say ,this function will transfer a string like ip address into a numeric ip address.
Test :
int main(){
int sockfd = socket(AF_INET,SOCK_RAW,0);
struct sockaddr_in server_sock_in;
bzero(&server_sock_in,sizeof(struct sockaddr_in));
server_sock_in.sin_family=AF_INET;
inet_aton("14.17.42.40",&(server_sock_in.sin_addr));
printf("\nThe host 14.17.42.40 after aton function:\n%X\n",server_sock_in.sin_addr.s_addr);
}
and the test result is like that:
The host 14.17.42.40 after aton function:
282A110E
According to the test above ,we can see how the function inet_aton works:
1. first , this function translate ‘14.17.42.40’ to big-endian like 0x0E 11 2A 28
2. then , this function will transfer big-endian to little endian if your system is little endian.0x 0E 11 2A 28–>0x 28 2A 11 0E