msdngetnameinfo The getnameinfo function provides name resolution from an address to the host name. int getnameinfo( const struct sockaddr FAR *sa, socklen_t salen, char FAR *host, DWORD hostlen, char FAR *serv, DWORD servlen, int flags ); Parameters sa [in] Pointer to a socket address structure containing the address and port number of the socket. For IPv4, the sa parameter points to a sockaddr_in structure; for IPv6, the sa parameter points to a sockaddr_in6 structure. salen [in] Length of the structure pointed to in the sa parameter. host [out] Pointer to the host name. The host name is returned as a Fully Qualified Domain Name (FQDN) by default. hostlen [in] Length of the buffer pointed to by the host parameter. The caller must provide a buffer large enough to hold the host name, including terminating NULL characters. A value of zero indicates the caller does not want to receive the string provided in host. serv [out] Pointer to the service name associated with the port number. servlen [in] Length of the buffer pointed to by the serv parameter. The caller must provide a buffer large enough to hold the service name, including terminating NULL characters. A value of zero indicates the caller does not want to receive the string provided in serv. flags [in] Flags used to customize processing of the getnameinfo function. See Res. Return Values Success returns zero. Any nonzero return value indicates failure.Res To simplify determining buffer requirements for the host and serv parameters, the following values for maximum host name length and maximum service name are defined in the Ws3tcpip.h header file:#define NI_MAXHOST 1025 #define NI_MAXSERV 32 The flags parameter can be used to customize processing of the getnameinfo function. The following flags are available: NI_NOFQDN NI_NUMERICHOST NI_NAMEREQD NI_NUMERICSERV NI_DGRAM When the NI_NAMEREQD flag is set, host names that cannot be resolved by Domain Name System (DNS) result in an error.Setting the NI_NOFQDN flag results in local hosts having only their Relative Distinguished Name (RDN) returned in the host parameter.Setting the NI_NUMERICHOST flag returns the numeric form of the host name instead of its name. The numeric form of the host name is also returned if the host name cannot be resolved by DNS. Setting the NI_NUMERICSERV flag returns the port number of the service instead of its name. Setting the NI_DGRAM flag indicates that the service is a datagram service. This flag is necessary for the few services that provide different port numbers for UDP and TCP service.Requirements Windows NT/2000/XP: Included in Windows XP and Windows .NET Server. Windows 95/98/Me: Unsupported. Header: Declared in Ws2tcpip.h.See Also sockaddr, getnameinfo
能否再说的详细点么?to pazee(耙子)
我现在是有了ip却不能得到机器名字!
The getnameinfo function provides name resolution from an address to the host name. int getnameinfo(
const struct sockaddr FAR *sa,
socklen_t salen,
char FAR *host,
DWORD hostlen,
char FAR *serv,
DWORD servlen,
int flags
);
Parameters
sa
[in] Pointer to a socket address structure containing the address and port number of the socket. For IPv4, the sa parameter points to a sockaddr_in structure; for IPv6, the sa parameter points to a sockaddr_in6 structure.
salen
[in] Length of the structure pointed to in the sa parameter.
host
[out] Pointer to the host name. The host name is returned as a Fully Qualified Domain Name (FQDN) by default.
hostlen
[in] Length of the buffer pointed to by the host parameter. The caller must provide a buffer large enough to hold the host name, including terminating NULL characters. A value of zero indicates the caller does not want to receive the string provided in host.
serv
[out] Pointer to the service name associated with the port number.
servlen
[in] Length of the buffer pointed to by the serv parameter. The caller must provide a buffer large enough to hold the service name, including terminating NULL characters. A value of zero indicates the caller does not want to receive the string provided in serv.
flags
[in] Flags used to customize processing of the getnameinfo function. See Res.
Return Values
Success returns zero. Any nonzero return value indicates failure.Res
To simplify determining buffer requirements for the host and serv parameters, the following values for maximum host name length and maximum service name are defined in the Ws3tcpip.h header file:#define NI_MAXHOST 1025
#define NI_MAXSERV 32
The flags parameter can be used to customize processing of the getnameinfo function. The following flags are available: NI_NOFQDN
NI_NUMERICHOST
NI_NAMEREQD
NI_NUMERICSERV
NI_DGRAM
When the NI_NAMEREQD flag is set, host names that cannot be resolved by Domain Name System (DNS) result in an error.Setting the NI_NOFQDN flag results in local hosts having only their Relative Distinguished Name (RDN) returned in the host parameter.Setting the NI_NUMERICHOST flag returns the numeric form of the host name instead of its name. The numeric form of the host name is also returned if the host name cannot be resolved by DNS. Setting the NI_NUMERICSERV flag returns the port number of the service instead of its name. Setting the NI_DGRAM flag indicates that the service is a datagram service. This flag is necessary for the few services that provide different port numbers for UDP and TCP service.Requirements
Windows NT/2000/XP: Included in Windows XP and Windows .NET Server.
Windows 95/98/Me: Unsupported.
Header: Declared in Ws2tcpip.h.See Also
sockaddr, getnameinfo
================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★ 浏览帖子速度极快![建议系统使用ie5.5以上]。 ★ 多种帖子实现界面。
★ 保存帖子到本地[html格式]★ 监视您关注帖子的回复更新。
★ 可以直接发贴、回复帖子★ 采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录!
★ 支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名 ●
可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
Http://www.ChinaOK.net/csdn/csdn.rar
Http://www.ChinaOK.net/csdn/csdn.exe [自解压]