CAsyncSocket -> OnReceive -> Receive does not remove data in the queue?
- From: FFMG <spambucket@xxxxxxxxxxxx>
- Date: Tue, 6 Jan 2009 07:24:40 -0800 (PST)
Hi,
I have data that is send from on socket to another.
As per the documentation, for every OnReceive( ... ) I call one Receive
( buffer, 4096 ) only.
I then handle the buffer of data, I read 8 bytes of data and that
tells me how many bytes I need to still read.
I then 'store' whatever bytes are left behind and on the next
'OnReceive( ... )' I add those bytes that were left over from the
previous operation and read the next 'batch' of 4096 bytes.
And I do that over and over again, hopefully all the data is in the
right order and everything should work out.
The problem is that some of the data I receive, by definition, cause
other windows or dialogs to appear and, because it has its own message
pump it causes another OnReceive( ... ) to be called _with the same
data_
In other words I am reading the same 4096 bytes again.
My understanding was that calling 'Receive( buffer, 4096 )' would
remove the data from the queue, making sure that it is only read once.
Obviously this causes problems when I am trying to unpack the data as
now everything is invalid.
What could be causing the problem, and more importantly, how do I
ensure that the data that I am reading is always new data and not data
that I have already read.
Simon
.
- Follow-Ups:
- Re: CAsyncSocket -> OnReceive -> Receive does not remove data in the queue?
- From: Joseph M . Newcomer
- Re: CAsyncSocket -> OnReceive -> Receive does not remove data in the queue?
- From: Scott McPhillips [MVP]
- Re: CAsyncSocket -> OnReceive -> Receive does not remove data in the queue?
- Prev by Date: Re: resource editor VS2008 vs VC6
- Next by Date: Re: Why we have seperate Create(…) in MFC
- Previous by thread: resource editor VS2008 vs VC6
- Next by thread: Re: CAsyncSocket -> OnReceive -> Receive does not remove data in the queue?
- Index(es):
Relevant Pages
|