• Advertisement

Archived

This topic is now archived and is closed to further replies.

MSG_PEEK not working as advertised (WinSock)

This topic is 5620 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The documentation (MSDN) says that this:
SOCKET s;
// connect ...
char buffer[32];
int len = recv(s,buffer,32,MSG_PEEK);
 
Copies the data into the buffer, but doesn''t remove it from the pending queue of incoming data, and then returns the amount of data in the queue:
quote:
MSDN: MSG_PEEK: Peeks at the incoming data. The data is copied into the buffer but is not removed from the input queue. The function then returns the number of bytes currently pending to receive.
However, whenever I try to do this, and call recv with a value I know is less than the amount of incoming bytes, recv always returns the value I pass it.
  

// Say there''s 60 incoming bytes

char recvbuf[32]; // only space for 32

int len = recv(s,recvbuf,32,MSG_PEEK);
// len should now equal 60, right?

// then why does it ALWAYS RETURN 32?!?!?

  
Am I just on crack? Is there something I''m not getting? Or is MSDN just blatantly wrong? And! If so, how do I go about finding the amount of data pending without going Asynchronous?

Share this post


Link to post
Share on other sites
Advertisement
Have a look at this:
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q140263&

Share this post


Link to post
Share on other sites

  • Advertisement