请输入您要查询的百科知识:

 

词条 inet_ntoa
释义

基本介绍

功能:

将一个IP转换成一个互联网标准点分格式的字符串。

原型:

char FAR * inet_ntoa( struct in_addr in);

头文件:

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 returns a character pointer to a static buffer containing the text address in standard ".'' notation. Otherwise, it returns NULL.

Remarks The inet_ntoa function takes an Internet address structure specified by the in parameter and returns an ASCII string representing the address in ".'' (dot) notation as in "a.b.c.d.'' The string returned by inet_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;

addrSrv.sin_addr.S_un.S_addr=inet_addr("127.0.0.1");

char recvBuf[100];

char tempBuf[100];

sprintf(tempBuf,"%s say: %s",inet_ntoa(addrSrv.sin_addr),recvBuf);

//将sin_addr储存的IP(127.0.0.1)转换成字符串形式。

随便看

 

百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。

 

Copyright © 2004-2023 Cnenc.net All Rights Reserved
更新时间:2025/1/11 12:19:39