Welcome![Sign In][Sign Up]
Location:
Search - gethostbyaddr

Search list

[TCP/IP stacktcp-ipayixidailv

Description: 一个简单的TCP客户端程序流程 1、使用WSAStartup()初始化WinSock库。 2、使用socket()创建一个IPPROTO_TCP SOCKET。 3、使用gethostbyname()/gethostbyaddr()获取主机信息。 4、使用connect()和我们创建的套接字连接服务器。 5、使用send()/recv()发送和接收数据,直到我们的TCP会话结束。 6、使用closesocket()关闭套接字连接。 7、使用WSACleanup()释放WinSock。 -a simple TCP client a process, the use of WSAStartup () initialization WinSock library. 2, the use of socket () to create a IPPROTO_TCP SOCKET. 3, the use of gethostbyname () / gethostbyaddr () mainframe access information. 4, the use of connect (), and we create the socket connections server. 5, the use of send () / recv () to send and receive data until we TCP end of the session. 6, the use of closesocket () closes socket connections. 7, the use of WSACleanup () release WinSock.
Platform: | Size: 5096 | Author: 顾谦 | Hits:

[Internet-NetworkGetIPAddress

Description: 该实例通过Winsock函数gethostname,gethostbyname和gethostbyaddr获得主机IP和主机名-example through the Winsock function gethostname. gethostbyname and gethostbyaddr was host IP and hostname
Platform: | Size: 33687 | Author: 赵亮 | Hits:

[assembly languagehostlab

Description: find the information about a host with the DNS retrieving system calls, such as gethostbyname() and gethostbyaddr(). (2) All the required information are in the hostent structure. (3) All the aliases and IP addresses of the host is stored in the hostent structure using linked list (链表).
Platform: | Size: 1258 | Author: 韩雪雁 | Hits:

[Internet-Network一个判断远程主机存活程序代码

Description: 一个判断远程主机存活程序代码(ping) #include #include #include #include #include "winsock.h" #pragma comment(lib,"Ws2_32"); #define SEND_SIZE 32 #define PACKET_SIZE 4096 #define ICMP_ECHO 8 #define ICMP_ECHOREPLY 0 struct icmp { unsigned char icmp_type; unsigned char icmp_code; unsigned short icmp_cksum; unsigned short icmp_id; unsigned short icmp_seq; unsigned long icmp_data; }; struct ip { unsigned char ip_hl:4; unsigned char ip_v:4; unsigned char ip_tos; unsigned short ip_len; unsigned short ip_id; unsigned short ip_off; unsigned char ip_ttl; unsigned char ip_p; unsigned short ip_sum; unsigned long ip_src; unsigned long ip_dst; }; unsigned char sendpacket[PACKET_SIZE]; unsigned char recvpacket[PACKET_SIZE]; struct sockaddr_in dest_addr; struct sockaddr_in from_addr; int sockfd; int pid; unsigned short cal_chksum(unsigned short *addr,int len); int pack(int pack_no); int unpack(unsigned char *buf,int len); void send_packet(void); void recv_packet(void); void main(int argc,char *argv[]) { struct hostent *host; struct protoent *protocol; WSADATA wsaData; int timeout=1000; int SEND_COUNT=4; int i; char *par_host; par_host=argv[argc-1]; //IP赋值 switch(argc) { case 2: break; case 3: if(strcmp(argv[1],"-t")==0) { SEND_COUNT=10000; break; } //fall through default: printf("usage: %s [-t] Host name or IP address\n",argv[0]); exit(1); } if(WSAStartup(0x1010,&wsaData)!=0) { printf("wsastartup error\n"); exit(1); } if( (protocol=getprotobyname("icmp") )==NULL) { printf("getprotobyname error\n"); exit(1); } /* printf("%s\n",protocol->p_name); printf("%s\n",protocol->p_aliases); printf("%d\n",protocol->p_proto); system("pause"); */ if( (sockfd=socket(AF_INET,SOCK_RAW,protocol->p_proto) )<0) { printf("socket error\n"); exit(1); } if(setsockopt(sockfd,SOL_SOCKET,SO_RCVTIMEO,(char*)&timeout,sizeof(timeout))h_length); //resolve address to hostname if(host=gethostbyaddr(host->h_addr,4,PF_INET)) par_host=host->h_name; // //printf("%s\n",par_host); // } else if( dest_addr.sin_addr.s_addr=inet_addr(par_host)==INADDR_NONE) { printf("Unkown host %s\n",par_host); exit(1); } pid=getpid(); /* printf("%d\n",pid); system("pause"); */ printf("Pinging %s [%s]: with %d bytes of data:\n\n",par_host,inet_ntoa(dest_addr.sin_addr),SEND_SIZE); for(i=0;i1) { sum+=*w++; nleft-=2; } if( nleft==1) { *(unsigned char *)(&answer)=*(unsigned char *)w; sum+=answer; } sum=(sum>>16)+(sum&0xffff); sum+=(sum>>16); answer=~sum; return answer; } //打包 int pack(int pack_no) { int packsize; struct icmp *icmp; packsize=8+SEND_SIZE; icmp=(struct icmp*)sendpacket; icmp->icmp_type=ICMP_ECHO; icmp->icmp_code=0; icmp->icmp_cksum=0; icmp->icmp_seq=pack_no; icmp->icmp_id=pid; icmp->icmp_data=GetTickCount(); icmp->icmp_cksum=cal_chksum( (unsigned short *)icmp,packsize); /*校验算法*/ return packsize; } //解包 int unpack(unsigned char *buf,int len) { struct ip *ip; struct icmp *icmp; double rtt; int iphdrlen; ip=(struct ip *)buf; iphdrlen=ip->ip_hl*4; icmp=(struct icmp *)(buf+iphdrlen); if( (icmp->icmp_type==ICMP_ECHOREPLY) && (icmp->icmp_id==pid) ) { len=len-iphdrlen-8; rtt=GetTickCount()-icmp->icmp_data; printf("Reply from %s: bytes=%d time=%.0fms TTL=%d icmp_seq=%u\n", inet_ntoa(from_addr.sin_addr), len, rtt, ip->ip_ttl, icmp->icmp_seq); return 1; } return 0; } //发送 void send_packet() { int packetsize; static int pack_no=0; packetsize=pack(pack_no++); if( sendto(sockfd,(char *)sendpacket,packetsize,0,(struct sockaddr *)&dest_addr,sizeof(dest_addr) )=0) success=unpack(recvpacket,n); else if (WSAGetLastError() == WSAETIMEDOUT) { printf("Request timed out.\n"); return; } }while(!success); } UID5380 帖子239 精华0 积分1289 阅读权限40 来自软件学院 在线时间81 小时 注册时间2006-5-22 最后登录2007-2-24 查看详细资料 TOP
Platform: | Size: 5881 | Author: shuiyuan313 | Hits:

[Internet-Network实例70

Description: WINSOCK程序设计共分为客户端和服务器端程序两部分,要求实现功能:服务器端要能监听客户端连接请求,为客户端的连接请求建立SOCKET队列,处理各个客户端发送的数据,并向响应客户端发送应答信息,更新服务器端的端口号。-Winsock program design consists of client and server-side procedures in two parts, requires the function : server can be monitored to client requests for the client to establish a link SOCKET queue handle all the client to send data to respond to a client sent response information update service Works on the port side.
Platform: | Size: 45056 | Author: 和平鸽 | Hits:

[TCP/IP stacktcp-ipayixidailv

Description: 一个简单的TCP客户端程序流程 1、使用WSAStartup()初始化WinSock库。 2、使用socket()创建一个IPPROTO_TCP SOCKET。 3、使用gethostbyname()/gethostbyaddr()获取主机信息。 4、使用connect()和我们创建的套接字连接服务器。 5、使用send()/recv()发送和接收数据,直到我们的TCP会话结束。 6、使用closesocket()关闭套接字连接。 7、使用WSACleanup()释放WinSock。 -a simple TCP client a process, the use of WSAStartup () initialization WinSock library. 2, the use of socket () to create a IPPROTO_TCP SOCKET. 3, the use of gethostbyname ()/gethostbyaddr () mainframe access information. 4, the use of connect (), and we create the socket connections server. 5, the use of send ()/recv () to send and receive data until we TCP end of the session. 6, the use of closesocket () closes socket connections. 7, the use of WSACleanup () release WinSock.
Platform: | Size: 5120 | Author: 顾谦 | Hits:

[Internet-NetworkGetIPAddress

Description: 该实例通过Winsock函数gethostname,gethostbyname和gethostbyaddr获得主机IP和主机名-example through the Winsock function gethostname. gethostbyname and gethostbyaddr was host IP and hostname
Platform: | Size: 33792 | Author: 赵亮 | Hits:

[assembly languagehostlab

Description: find the information about a host with the DNS retrieving system calls, such as gethostbyname() and gethostbyaddr(). (2) All the required information are in the hostent structure. (3) All the aliases and IP addresses of the host is stored in the hostent structure using linked list (链表). -find the information about a host with the DNS retrieving system calls, such as gethostbyname () and gethostbyaddr (). (2) All the required information are in the hostent structure. (3) All the aliases and IP addresses of the host is stored in the hostent structure using linked list (linked list).
Platform: | Size: 1024 | Author: 韩雪雁 | Hits:

[Web ServerDelphi-by-IP-address.Rar

Description: h := gethostbyaddr(@addr.sin_addr.s_addr, sizeof(addr), AF_INET) - h := gethostbyaddr(@addr.sin_addr.s_addr, sizeof(addr), AF_INET)
Platform: | Size: 6144 | Author: 美uzu | Hits:

[Internet-Networkhttppc-0.8.5.tar

Description: linux下穿代理的socket程序.HTTP Proxy Client is the small set of libraries and scripts, which provides transparent access to Internet via HTTP proxy for programs, which uses TCP/IP for communication. The list of programs includes: telnet, ftp, ssh, cvs, smth else? Project implements dynamic library, that can be preloaded before program run. The library substitutes some system calls (connect(), gethostbyaddr(), gethostbyname()), with calls, which makes TCP/IP connection through HTTP proxy. This allows client programs behind HTTP proxy work with Internet without limitations. -HTTP Proxy Client is the small set of libraries and scripts, which provides transparent access to Internet via HTTP proxy for programs, which uses TCP/IP for communication. The list of programs includes: telnet, ftp, ssh, cvs, smth else? Project implements dynamic library, that can be preloaded before program run. The library substitutes some system calls (connect(), gethostbyaddr(), gethostbyname()), with calls, which makes TCP/IP connection through HTTP proxy. This allows client programs behind HTTP proxy work with Internet without limitations.
Platform: | Size: 217088 | Author: 李冰 | Hits:

[Internet-Networkgethostbyaddr

Description: Linux 下C语言写的获取主机IP地址的源码-Linux written in C language source code for the host IP address
Platform: | Size: 1024 | Author: linjiandao | Hits:

[Internet-Networkq.6

Description: gethostbyaddr s socket programming program
Platform: | Size: 7168 | Author: P | Hits:

[Internet-NetworkAdvanced-Socket-Programs-SCTP-Setsock-thread-safe

Description: This document contains all easy-to-get and simple tcp/ip socket programs. like thread safe version of gethostbyaddr, sctp programs, ping c code, setsockopt&getsockopt programs
Platform: | Size: 1054720 | Author: imranity | Hits:

CodeBus www.codebus.net