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)) )
{
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);