Re: Problems with CAsyncSocket.
- From: "Josh McFarlane" <darsant@xxxxxxxxx>
- Date: 29 Mar 2006 13:09:09 -0800
TonyG wrote:
But... On my slow laptop, if I am receiving a large packet, when I perform
the "Receive", I will get exactly the entire packet. Occasionally on my
laptop and usually always on an different PC (faster?) I will receive only
the first part of the packet. The amount varies somewhat, but is around 50%.
I will usually get another OnReceive call where I will get the remaining
part of the packet.
Is it suppose to work this way?
Yes, that's the way the asych socket works.
It guarantees you'll receive the data in the order you sent it, but
guarantees nothing about how many calls it will take to receive it.
In your OnReceive, you should assume nothing about the length of the
data you will receive.
You could receive:
1. Nothing
2. a part of a package.
3. A full package
4. More than one full package (Maybe 2, maybe 1 and a half, etc).
So, all you can do is receive the data that's available, then parse it
to see if you've received a full package, and handle it appropriately
if you have, and then go back to receiving.
Just remember that the only real thing you can assume about the
incoming data is that it will get there eventually (assuming the
connection stays open), and it will be in the same order that it was
sent in.
Josh McFarlane
.
- References:
- Problems with CAsyncSocket.
- From: TonyG
- Problems with CAsyncSocket.
- Prev by Date: Re: a container supports keys (similar to the set in STL)
- Next by Date: Re: Problems with CAsyncSocket.
- Previous by thread: Re: Problems with CAsyncSocket.
- Index(es):
Relevant Pages
|