単純ブラシシステムc言語実装

3110 ワード

/*
 *	      
 *
 *	    [email protected]
 */
#include 
#include 
#include 

#pragma comment(lib,"ws2_32")

#define RefreshTimes 10						//    
char host[128];
char path[128];

//     
DWORD  WINAPI   SendThread(LPVOID lpParam);
void            SetParam();
	

void main(int argc,char * argv[])
{
	HANDLE          hThread[RefreshTimes];
	DWORD           dwThread[RefreshTimes];
	int i;
	
	SetParam();								//       
	
	//               
	for( i = 0 ; i < RefreshTimes ; i++ )
	{
		hThread[i] = CreateThread(NULL,0,SendThread,(LPVOID)i,0,&dwThread[i]);
		if( hThread == NULL )
		{
			printf("\tCreateThread Failed.
"); exit(0); } Sleep(100); CloseHandle(hThread); } } // , DWORD WINAPI SendThread(LPVOID lpParam) { WSADATA wsd; SOCKET local; SOCKADDR_IN addr; HOSTENT * Host = NULL; if( WSAStartup(MAKEWORD(2,2),&wsd) != 0) { printf("\tFailed To Load Winsock Library!
"); exit(0); } local = socket(AF_INET,SOCK_STREAM,0); if( local == INVALID_SOCKET) { printf("\tFailed To Create Socket
"); exit(0); } addr.sin_family = AF_INET; addr.sin_port = htons(80); addr.sin_addr.S_un.S_addr = inet_addr(host); if( addr.sin_addr.S_un.S_addr == INADDR_NONE ) { // Host = gethostbyname(host); if( Host == NULL ) { printf("\tUnable To Resolve Server:%s
",host); return 0; } CopyMemory(&addr.sin_addr,Host->h_addr_list[0],Host->h_length); printf("\tSend To:%s
",inet_ntoa(addr.sin_addr)); } // if( SOCKET_ERROR == connect(local,(sockaddr*)&addr,sizeof(SOCKADDR)) ) { printf("\tFailed To Connect To The Server!
"); exit(0); } // char SendBuf[512]; memset(SendBuf,'\0',512); strcpy(SendBuf,"GET "); char PartOne[] = " HTTP/1.1\r
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*\r
Accept-Language: zh-cn\r
Accept-Encoding: gzip, deflate\r
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r
Host: "; char PartTwo[] = "\r
Connection: Keep-Alive\r
\r
"; strcat(SendBuf,path); strcat(SendBuf,PartOne); strcat(SendBuf,host); strcat(SendBuf,PartTwo); // if( send(local,SendBuf,strlen(SendBuf)+1,0) == SOCKET_ERROR ) { printf("\tSend Data Error.
"); } closesocket(local); WSACleanup(); return 0; } void SetParam() { char Host_Temp[128]; char Path_Temp[128]; printf("
\tMade By
\tQQ:542335496
\tEmail:[email protected]
"); printf("\tGet The Host:"); gets(Host_Temp); fflush(stdout); strcpy(host,&Host_Temp[0]); printf("\tGet The Path of WebPage:"); gets(Path_Temp); strcpy(path,&Path_Temp[0]); }