Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


recv problem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Mar 24, 2009 5:06 pm    Post subject: recv problem Reply with quote

hello,

I'm coding my own little http lib atm and I'm having a problem with recv.

Code:
   int bytes_read;
   char rvBuffer[512];
   string h_body;
   string response;
   do
   {
      bytes_read = recv(s, rvBuffer, sizeof(rvBuffer), 0);
      response += rvBuffer;

      if(response.find(RHTTP_CONTENT_END) != -1)
      {
         //h_body.assign(response, response.find("\r\n\r\n")+4, response.length());
         //h_body.assign(h_body, 0, h_body.length()-8);
         //printf("%d\n", h_body.c_str()[h_body.length()]);
         break;
      }

   }
   while ( bytes_read > 0 );
   printf("response: %s\n", response.c_str());

So the while-loop to recv only breaks if the socket was closed or R_HTTP_CONTENT_END was found in response. But later when it printfs out the response it appears to ALWAYS replaces the bytes of the last packet with very weird bytes.
I'm very confused because this always only happens with the last packet reviced.
What's happening to them?

Edit: I forgot to call ZeroMemory() on rvBuffer. Hmm weird how it acts when I don't call it though.

Thanks ..to myself Lol.

Edit2: Also using std:string+= isn't that good, I suggest using std:string.append(rvBuf, bytes_recv).
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites