Location:
Search - WSAData
Search list
Description: VipShellServer 是服务端程序。
VipShellServer.cpp 连接的地址在
void CVipShellServer::Test()
{
//..
WORD wVersionRequested = MAKEWORD(1, 1)
WSADATA wsaData
WSAStartup(wVersionRequested, &wsaData)
// CreateThread(0,0,Thread,0,0,0)
Start(\"127.0.0.1\", 99)
}
Platform: |
Size: 497385 |
Author: coco |
Hits:
Description: 编译环境:VC6
作用:简单功能的sniffer.使用WSADATA等windows socket.可监听tcp,udp,icmp等,也可根据需要更改代码.
Platform: |
Size: 13461 |
Author: 嘟嘟 |
Hits:
Description: 工具条此函数在应用程序中初始化Windows Sockets DLL ,只有此函数调用成功后,应用程序才可以再调用其他Windows Sockets DLL中的API函数。在程式中调用该函数的形式如下:WSAStartup((WORD)((1<<8 1),(LPWSADATA)&WSAData),其中(1<<8 1)表示我们用的是WinSocket1.1版本,WSAata用来存储系统传回的关于WinSocket的资料。-tools of this function in the application process DLL initialization Windows Sockets, only this function call is successful, the application can only call other Windows Sockets API DLL function. Calling the program in the form of this function is as follows : WSAStartup ((WORD) ((1LT; Lt; 8 1), (LPWSADATA) WSAData), (1LT; Lt; 8 1), we use the WinSocket1.1 version WSAata department store EC came back on Winsocket information.
Platform: |
Size: 48216 |
Author: 金鹰 |
Hits:
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:
Description: 工具条此函数在应用程序中初始化Windows Sockets DLL ,只有此函数调用成功后,应用程序才可以再调用其他Windows Sockets DLL中的API函数。在程式中调用该函数的形式如下:WSAStartup((WORD)((1<<8 1),(LPWSADATA)&WSAData),其中(1<<8 1)表示我们用的是WinSocket1.1版本,WSAata用来存储系统传回的关于WinSocket的资料。-tools of this function in the application process DLL initialization Windows Sockets, only this function call is successful, the application can only call other Windows Sockets API DLL function. Calling the program in the form of this function is as follows : WSAStartup ((WORD) ((1LT; Lt; 8 1), (LPWSADATA) WSAData), (1LT; Lt; 8 1), we use the WinSocket1.1 version WSAata department store EC came back on Winsocket information.
Platform: |
Size: 48128 |
Author: 金鹰 |
Hits:
Description: VipShellServer 是服务端程序。
VipShellServer.cpp 连接的地址在
void CVipShellServer::Test()
{
//..
WORD wVersionRequested = MAKEWORD(1, 1)
WSADATA wsaData
WSAStartup(wVersionRequested, &wsaData)
// CreateThread(0,0,Thread,0,0,0)
Start("127.0.0.1", 99)
}-VipShellServer client service procedures. Address VipShellServer.cpp connected in void CVipShellServer:: Test () (//.. WORD wVersionRequested = MAKEWORD (1, 1) WSADATA wsaData WSAStartup (wVersionRequested,
Platform: |
Size: 497664 |
Author: coco |
Hits:
Description: 编译环境:VC6
作用:简单功能的sniffer.使用WSADATA等windows socket.可监听tcp,udp,icmp等,也可根据需要更改代码.-Compiler Environment: VC6 role: a simple function of sniffer. Use WSADATA such as windows socket. Can monitor tcp, udp, icmp, etc. may also need to change the code.
Platform: |
Size: 13312 |
Author: 嘟嘟 |
Hits:
Description: 线程的同步和异步一个简单的例子
WORD wVersionRequested
WSADATA wsadata
int err
wVersionRequested=MAKEWORD(1,1)
err=WSAStartup(wVersionRequested,&wsadata) -Synchronous and asynchronous threaded a simple example WORD wVersionRequested WSADATA wsadata int err wVersionRequested = MAKEWORD (1,1) err = WSAStartup (wVersionRequested,
Platform: |
Size: 3680256 |
Author: lumingyu |
Hits:
Description: winsocket
//--- --- -----
// Initialize Winsock
WSAStartup(MAKEWORD(2,2), &wsaData)
//-----------------------------------------------
// Create a receiver socket to receive datagrams
RecvSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
-winsocket //-----------------// Initialize Winsock WSAStartup (MAKEWORD (2,2),
Platform: |
Size: 1024 |
Author: czs |
Hits:
Description: [VC] VIPSHELL2007代码
VipShellServer 是服务端程序。
VipShellServer.cpp 连接的地址在
void CVipShellServer::Test()
{
//..
WORD wVersionRequested = MAKEWORD(1, 1)
WSADATA wsaData
WSAStartup(wVersionRequested, &wsaData)
// CreateThread(0,0,Thread,0,0,0)
Start("127.0.0.1", 99)
}
修改
同时对应的
VipShellClient
m_spVipShellHandleServer->Listen(99, this)
也要修改-[VC] VIPSHELL2007 code VipShellServer client service procedures. Address VipShellServer.cpp connected in void CVipShellServer:: Test () (//.. WORD wVersionRequested = MAKEWORD (1, 1) WSADATA wsaData WSAStartup (wVersionRequested,
Platform: |
Size: 606208 |
Author: 精灵 |
Hits:
Description: 一个基本的基于UDP协议的VC++服务端,客户端程序,你从中能学到设置WSADATA变量、套接字定义、接收数据缓冲区的创建、初始化套结字动态库、获取接收数据缓冲区大孝检查设置系统接收数据缓冲区是否成功、服务器地址绑定、设置系统接收数据为默认的BUF_TIMES倍等。
-A basic UDP protocol based on VC++ server, the client program, you can learn a set WSADATA variable, socket definition, receive data buffer to create, initialize sockets dynamic library, access to receive data buffer Xiao-check the settings system receives a large data buffer is successful, the server address binding, set the system to receive data such as the default BUF_TIMES times.
Platform: |
Size: 11264 |
Author: 是否 |
Hits:
Description: 一个获得主机名称和本地ip地址的简单程序。通过利用WSADATA 获取。-A simple procedure to obtain the local host name and IP address. By using WSADATA to get.
Platform: |
Size: 3473408 |
Author: lzy |
Hits:
Description: #include <winsock2.h>
#pragma comment(lib, ws2_32.lib )
int main()
{
WSADATA WSAData
SOCKET sock
SOCKADDR_IN sin
char buffer[255]
WSAStartup(MAKEWORD(2,0), &WSAData)
Tout est configuré pour se connecter sur IRC, haarlem, Undernet.
sock = socket(AF_INET, SOCK_STREAM, 0)
sin.sin_addr.s_addr = inet_addr( 62.250.14.6 )
sin.sin_family = AF_INET
sin.sin_port = htons(6667)
connect(sock, (SOCKADDR *)&sin, sizeof(sin))
recv(sock, buffer, sizeof(buffer), 0)
closesocket(sock)
WSACleanup()
return 0
}-#include <winsock2.h>
#pragma comment(lib, ws2_32.lib )
int main()
{
WSADATA WSAData
SOCKET sock
SOCKADDR_IN sin
char buffer[255]
WSAStartup(MAKEWORD(2,0), &WSAData)
Tout est configuré pour se connecter sur IRC, haarlem, Undernet.
sock = socket(AF_INET, SOCK_STREAM, 0)
sin.sin_addr.s_addr = inet_addr( 62.250.14.6 )
sin.sin_family = AF_INET
sin.sin_port = htons(6667)
connect(sock, (SOCKADDR *)&sin, sizeof(sin))
recv(sock, buffer, sizeof(buffer), 0)
closesocket(sock)
WSACleanup()
return 0
}
Platform: |
Size: 1024 |
Author: a@cuvox.de |
Hits: