C語(yǔ)言inet_ntoa()函數(shù):將網(wǎng)絡(luò)二進(jìn)制的數(shù)字轉(zhuǎn)換成網(wǎng)絡(luò)地址
頭文件:
1
|
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> |
定義函數(shù):
1
|
char * inet_ntoa( struct in_addr in); |
函數(shù)說(shuō)明:inet_ntoa()用來(lái)將參數(shù)in 所指的網(wǎng)絡(luò)二進(jìn)制的數(shù)字轉(zhuǎn)換成網(wǎng)絡(luò)地址, 然后將指向此網(wǎng)絡(luò)地址字符串的指針?lè)祷?
返回值:成功則返回字符串指針, 失敗則返回NULL.
C語(yǔ)言inet_aton()函數(shù):將網(wǎng)絡(luò)地址轉(zhuǎn)成網(wǎng)絡(luò)二進(jìn)制的數(shù)字
頭文件:
1
|
#include <sys/scoket.h> #include <netinet/in.h> #include <arpa/inet.h> |
定義函數(shù):
1
|
int inet_aton( const char * cp, struct in_addr *inp); |
函數(shù)說(shuō)明:inet_aton()用來(lái)將參數(shù)cp 所指的網(wǎng)絡(luò)地址字符串轉(zhuǎn)換成網(wǎng)絡(luò)使用的二進(jìn)制的數(shù)字, 然后存于參數(shù)inp 所指的in_addr 結(jié)構(gòu)中.
結(jié)構(gòu)in_addr 定義如下
1
2
3
4
|
struct in_addr { unsigned long int s_addr; }; |
返回值:成功則返回非0 值, 失敗則返回0.
C語(yǔ)言inet_addr()函數(shù):將網(wǎng)絡(luò)地址轉(zhuǎn)成二進(jìn)制的數(shù)字
頭文件:
1
|
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> |
定義函數(shù):
1
|
unsigned long int inet_addr( const char *cp); |
函數(shù)說(shuō)明:inet_addr()用來(lái)將參數(shù)cp 所指的網(wǎng)絡(luò)地址字符串轉(zhuǎn)換成網(wǎng)絡(luò)所使用的二進(jìn)制數(shù)字. 網(wǎng)絡(luò)地址字符串是以數(shù)字和點(diǎn)組成的字符串, 例如:"163. 13. 132. 68".
返回值:成功則返回對(duì)應(yīng)的網(wǎng)絡(luò)二進(jìn)制的數(shù)字, 失敗返回-1.