Linux and C[2]: What is the function of inet_aton or inet ntoa ?
来源:互联网 发布:赌博软件破解 编辑:程序博客网 时间:2024/06/06 04:20
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
0 0
- Linux and C[2]: What is the function of inet_aton or inet ntoa ?
- What is the difference between XML and C or C ?
- What is the difference between iface eth0 inet manual and iface eth0 inet static?
- what is the different between function and method in python
- What kinds of iterators of C++'s copy function requires? What about reverse or unique?
- What is the use of "?
- What is the significance of asmlinkage modifier in C?
- What is the role of the activation function in a neural network?
- What is the difference between fprintf and vfprintf in C++?
- what is the difference between definition and declaration in c
- What is the difference between -I and -L in makefile? and the means of -d.
- what is the location of the directory of c header files that match your running kernel -SLES11.2
- C++: How is the process of function calling in C++
- what's the function of pid file?
- What is the purpose of the USB?
- The State of Visual Analytics Views on what visual analytics is and where it is going
- What is the location of the directory of C header files that match your running kernel?
- What is the location of the directory of C header files that match your running kernel?
- 1090. Highest Price in Supply Chain
- 拉普拉斯变换 (有问题)
- Auto-Encoder相关介绍(转载)
- React Native 常见问题集合
- javascript基础--ajax
- Linux and C[2]: What is the function of inet_aton or inet ntoa ?
- 第七届蓝桥杯省赛Java语言C组_骰子游戏
- redis集群搭建
- javascript第一步
- eclipse环境下设置utf-8编码格式
- Google开源C++单元测试框架gTest 8:编写简单的测试框架
- 提高篇项目4.1--求组合数
- 算法竞赛入门经典ch3_ex2蛇形填数
- 我的第一个React Native App