更新时间:2022-10-24 17:02
功能:
将一个十进制网络字节序转换为点分十进制IP格式的字符串。
原型:
头文件:
arpa/inet.h
Winsock2.h
参数:
一个网络上的IP地址
返回值:
如果正确,返回一个字符指针,指向一块存储着点分格式IP地址的静态缓冲区(同一线程内共享此内存);错误,返回NULL。
The inet_ntoa function converts an (Ipv4) Internet network address into a string in Internet standard dotted format.
char FAR * inet_ntoa( struct in_addr in);
Parameters
in
[in] Structure that represents an Internet host address.
Return Values
If no error occurs, inet_ntoa
Remarks The inet_ntoa function takes an Internet address structure specified by the ininet_ntoa resides in memory that is allocated by Windows Sockets. The application should not make any assumptions about the way in which the memory is allocated. The data is guaranteed to be valid until the next Windows Sockets function call within the same thread—but no longer. Therefore, the data should be copied before another Windows Sockets call is made.
操作系统:Windows 2000 Professional 或更高版本
头文件:Winsock2.h
链接库:Ws2_32.lib
参见:
SOCKADDR_IN addrSrv;
char recvBuf[100];
char tempBuf[100];
//将sin_addr储存的IP(数值)转换成字符串形式(127.0.0.1)。