LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   network programming -- bad request (http://www.linuxquestions.org/questions/programming-9/network-programming-bad-request-233130/)

mehesque 09-20-2004 08:13 PM

network programming -- bad request
 
I'm trying to make a web crawler. But when I do a loop to fill the buffer, it fills then keeps doing recv() calls and those calls get BAD REQUESTS with only part of the downloaded file.

char tBuffer[kBufferSize];
int bytesRead = 1;
//bytesRead = recv(s,tempBuffer,bufferSize,0);
//recvBuffer=tempBuffer;
while (bytesRead>0){

bytesRead=recv(s,tBuffer,kBufferSize,0);
if(bytesRead==0){
cout << "##################################" << endl << "Done Reading From Site" << endl;
break;
}


acReadBuffer=acReadBuffer + tBuffer;
}
cout << acReadBuffer << endl;

Stack 09-20-2004 09:01 PM

Post the request your sending to the server.

mehesque 09-21-2004 01:28 PM

request
 
command = "GET / HTTP/1.1 \r\nHost: "+host_name+"\r\n\r\nConnection: Close\r\n";
cout << command;
err = send(s,command.c_str(),strlen(command.c_str()),0);


All times are GMT -5. The time now is 01:15 PM.