I cant seem to get it to write out the correct size to the .gif file,the original is 3kb but the new one i write to finishs with 1kb, can anyone help
Code:
cout << "Connected"<< endl;
std::string sendbuffer = "GET /apache_pb.gif HTTP/1.1\r\n"
"Host: 192.168.1.4\r\n\r\n";
// std::string buffer2 = "GET /apache_pb.gif HTTP/1.1\r\n Host: 192.168.1.4\r\n\r\n";
cout << sendbuffer.c_str() << endl;
nret = send(theSocket, sendbuffer.c_str(), sendbuffer.size(), 0);
std::string rbuffer;
rbuffer.resize(1024,0);
size_t sfind;
std::fstream fs;
fs.open ("apache_pb.gif", std::ifstream::binary,std::fstream::out);
nret = recv(theSocket, &rbuffer[0],1024,0);
if(nret > 0)
{
sfind = rbuffer.find("\r\n\r\n");
if(sfind != string::npos)
{
cout << nret << endl;
cout << "found" << endl;
fs.write (rbuffer.c_str()+sfind+4,((nret)-(sfind+4)));
}
}
while(1)
{
nret = recv(theSocket, &rbuffer[0],1024,0);
if(nret > 0)
{
cout << nret << endl;
fs.write (rbuffer.c_str(),nret);
}
else
{
break;
}
}
fs.close();
}
system("pause");