how divide herader from binary data

Posted by fixo2020 on Stack Overflow See other posts from Stack Overflow or by fixo2020
Published on 2010-05-21T15:23:37Z Indexed on 2010/05/21 15:50 UTC
Read the original article Hit count: 123

Filed under:

Hi, I have this code:

ofstream dest("test.txt",ios::binary);

 while (true){
  size_t retval = recv (sd, buffer, sizeof(buffer), 0);

   dest.write(buffer,retval);

 if(retval <= 0) { delete[] buffer; break;}
}

Now, the recv() function return 4 bytes each loop right? and buffer contain it, this return all data so, pseudo-header and binary data (image), but I want know how capture only binary data, I know that the end of header are "\n\r" right? but what's are the solution better for make this? I make a function that detect when are "\n\r"? and after how capture binary data? Or, I put all data in memory, and after parse it? but how? I'm desperate :(

© Stack Overflow or respective owner

Related posts about c++