Re: Problems with CAsyncSocket.



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

.



Relevant Pages

  • Re: Serial COM port communication problems
    ... The serial port receives char packets of different sizes, ... The receiving buffer is read by setting the mask to rx flag being the ... sub-packages arrive in succession and some sub-packages are lost. ... As for now the only way to get the hole package is by reading the ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Command: df
    ... > in which packet should I look??? ... a TCP packet. ... difference between a packet and a package.) ... Summary: The GNU core utilities: a set of tools commonly used in shell scripts ...
    (comp.os.linux.development.system)
  • Re: Packet Construction and Protocol Testing...
    ... :This is a set of Python libraries which make writing protocol testing ... :Summer of Code student I'm working with has also been using this ... :This code sends a quick and dirty, ICMPv4 ping packet on localhost. ... :currently a simple manual in the package. ...
    (freebsd-net)
  • Re: Ice Cream Directions Translation
    ... > Danny Wilde wrote: ... Add the contents of the Mix 1 package to the mixture, stir ... You would just add the packet, ...
    (sci.lang.japan)
  • Re: Actius MM10 modem
    ... telling me that "pppd exited with return value ... call retry delay timer expires) without waiting for an outbound packet. ... Shut down the link when idle-time seconds pass without receiving or ... The environment variable PPPHOME, if present, specifies the directory in ...
    (comp.os.linux.portable)