#include#include#pragma comment(lib,"WS2_32.lib")int main(){ WSADATA data; WSAStartup(2,&data); hostent* host = gethostbyname(""); char *IP = inet_nt....
分类:
其他好文 时间:
2014-06-28 12:28:59
阅读次数:
194
bool CDlgResetAlarmInfo::GetLocalUserNameAddIP(CString &a_lstrUserName ,CString &a_IpStr)
{
char buf[256]="";
WSADATA w;
WSAStartup(0x0101, &w);
struct hostent *ph = 0;
gethostname(buf, 256)...
分类:
编程语言 时间:
2014-06-17 16:38:03
阅读次数:
223
刚才学了gethostbyname函数,这个gethostbyaddr函数的作用是通过一个IPv4的地址来获取主机信息,并放在hostent结构体中。#include
struct hostent * gethostbyaddr(const char * addr, socklen_t len,.....
分类:
其他好文 时间:
2014-05-28 01:46:42
阅读次数:
331
只需调用一个函数即可gethostbyname(),gethostbyname()返回对应于给定主机名的包含主机名字和地址信息的hostent结构指针。结构的声明与gethostaddr()中一致。下面是函数原型:
Windows平台下 #include struct hostent FAR *PA...
分类:
系统相关 时间:
2014-05-26 11:27:30
阅读次数:
324
用域名获取IP地址或者用IP获取域名
#include
#include
#include
int main(int argc,char **aggv)
{
struct hostent *host;
char hostname[]="www.163.com";
char hostname2[]="www.baidu.com";
s...
分类:
系统相关 时间:
2014-05-15 06:15:07
阅读次数:
406