|
-
November 4th, 2006, 08:33 PM
#1
Improving speed and performance
Hello! I have a code that is searches a search engine like google, and then gets the results by getting the page source, and adds it to the list. But it seems to be pretty slow. I'm thinking about putting it on a separate thread to improve my program's performance. But for speed, it takes about 20-30 seconds, which is pretty slow... Anyways here is my code.
'Sending' is the CString that has the send data, that I'm about to send. Got is a array of char that collects the info, and finally collect a CString which the whole page source is collected.
Code:
hp=gethostbyname("www.thottbot.com");
server.sin_family= AF_INET;
server.sin_port=htons(80);
server.sin_addr.s_addr=*(unsigned long*)hp->h_addr;
if(connect(sClient, (struct sockaddr *)&server,sizeof(server)) ==SOCKET_ERROR)
{MessageBox("connect");
return;
}
send(sClient,sending,strlen(sending),0);
int cbRecvd=0;
while(cbRecvd=recv(sClient,got,39999,0))
{if(cbRecvd<0)
{
break;
}
got[cbRecvd] = '\0';
collect+=got;
UpdateData(FALSE);
}
Any suggestions to make this code faster?
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|