char hostaddr[15] = "bbs.gufeng.net";
SOCKET mSocket;
HOSTENT* hs = NULL;
SOCKADDR_IN addr;
char buff[10240];
WORD wVersionRequested = MAKEWORD( 2, 0 );
WSADATA wsa;
if(WSAStartup(wVersionRequested , &wsa))
{
cout<<"Init WinSocket Fail"<<endl;
return -1;
} mSocket = socket(AF_INET, SOCK_STREAM, 0); if( (addr.sin_addr.s_addr = inet_addr(hostaddr)) == INADDR_NONE)
{
if( (hs = gethostbyname(hostaddr)) == NULL)
{
cout<<"Analyse Host Address Fail"<<endl;
return -1;
} memcpy( &(addr.sin_addr.s_addr), hs->h_addr_list[0], hs->h_length);
cout<<"ip: "<<inet_ntoa(addr.sin_addr)<<endl;
}
addr.sin_family = AF_INET;
addr.sin_port = htons(80); if(connect(mSocket, (SOCKADDR*)(&addr), sizeof(addr)) == SOCKET_ERROR )
{
cout<<"Connect Host Fail"<<endl;
return -1;
} char buffpost[124] = "author=Aking&[email protected]&url=http%3A%2F%2F1test1&comment=3test3&submit=Leave+a+Comment&comment_post_ID=68"; int i = 10;
while (i--)
{
memset(buff, 0, 10240);
sprintf(buff, "POST /wp-comments-post.php HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* Referer: http://%s/?p=68#comment-14 Accept-Language: zh-cn Content-Type: application/x-www-form-urlencoded UA-CPU: x86 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727) Host: %s Content-Length: %d Connection: Keep-Alive Cache-Control: no-cache Cookie: __utma=182677680.4409620436596016000.1222237259.1222237259.1222237259.1; __utmb=182677680.1.10.1222237259; __utmc=182677680; __utmz=182677680.1222237259.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); comment_author_8e50a94f595e94e968a9ae39b9c15026=Aking; comment_author_email_8e50a94f595e94e968a9ae39b9c15026=Aking.Forever%40gmail.com; comment_author_url_8e50a94f595e94e968a9ae39b9c15026=http%3A%2F%2F1test1 %s", hostaddr, hostaddr, strlen(buffpost), buffpost);
send(mSocket, buff, strlen(buff), 0);
recv(mSocket, buff, 10240, 0);
} closesocket(mSocket);这个是我抓到的数据POST /wp-comments-post.php HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://blog.gufeng.net/?p=68#comment-14
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)
Host: blog.gufeng.net
Content-Length: 123
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: __utma=182677680.4409620436596016000.1222237259.1222237259.1222237259.1; __utmb=182677680.1.10.1222237259; __utmc=182677680; __utmz=182677680.1222237259.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); comment_author_8e50a94f595e94e968a9ae39b9c15026=Aking; comment_author_email_8e50a94f595e94e968a9ae39b9c15026=Aking.Forever%40gmail.com; comment_author_url_8e50a94f595e94e968a9ae39b9c15026=http%3A%2F%2F1test1author=Aking&[email protected]&url=http%3A%2F%2F1test1&comment=3test3&submit=Leave+a+Comment&comment_post_ID=68
解决方案 »
- TCP服务器接受数据问题
- VC6与VC2005速成版的windows.h
- 同一个程序可以打开多少次?
- 如何将已建好的对话框加入到了一个工程中?
- 怎么给按纽上加上 图标
- 网卡ping 得通 但装不起驱动 不知道是不是坏了 请高手指点指点?/
- 利用钩子进行钩键盘时,如何判断是哪些键,他们对应的是什么值?
- 急急急 ! 图象存储和显示的系列问题!!!!!!!!!
- 急!急! 如何动态生成象static label一样的控件? 第一个解决问题的 全分!
- 安装VC6之后文件不能正常打开
- 电子白板源代码最新版本v2.2
- m_wndSplitter.CreateStatic(this,1,2);,怎样去除分隔线?
Host: blog.gufeng.net