Re: Deaf CAsyncSocket on Windows Service.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Note that since you, at the application, have no idea how many packets are received, there
is no way that the receipt of multiple packets can fail to trigger on OnReceive. It is
assumed that packets arrive in a completely unpredictable temporal sequence (it could be
50ms between two packets, or 10 seconds) but in any case, if you get an OnReceive
notification, and delay in calling Receive, you might actually get the data of two or more
packets in your Receive call. You might get a packet-and-a-half, or 3.752 packets, and
you neither know nor care about how the packets are arriving. It is the responsibility of
the network stack to deal with the issues of reassembling a packet into a stream. The
point here is you have to stop thinking in terms of 'send' and 'recv' and think solely in
terms of streams of bytes; how the sender breaks up the output stream into packets, and
how the receiver reassembles the input packets into a stream, are details of
implementation of no consequence whatsoever. OnReceive notfications are sent whenever
there is data pending in the input buffer. For example the description of 'select' says

"...readability means that queued data is available for reading such that a call to
recv...is guaranteed not to block"

and in addition, the description of WSAAsyncSelect explicitly says that another read
notification will be issued if there is any data in the buffer.
joe

On Mon, 19 Jan 2009 18:51:24 -0500, "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp>
wrote:


"Stephen Myers" <StephenMyers@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5E3F541A-A5B5-4B47-8651-BA120F86CD9E@xxxxxxxxxxxxxxxx
Is there any posibility that the data is being received but not triggering
OnReceive()?

This can happen when two (or more) packets are received without a
Receive()
call. If you are doing the Receive() in as part of the OnReceive()
handling,
make sure there is no data left prior to exiting OnReceive().

Steve

On the contrary. Every call to Receive enables the message that will
produce the next call to OnReceive. It is therefore recommended that
Receive should be called only once per OnReceive notification. It is not
true that one must continue to call Receive until it would block.
(Reference: the MSDN page for WSAAsyncSelect - "an application need not read
all available data in response to an FD_READ message ? a single recv in
response to each FD_READ message is appropriate.")

And, if Receive is called more than once in OnReceive there is a possibility
that another OnReceive notification message (FD_READ) is left in the queue,
and when it is processed later there will be no data.

Suggestion: Call Receive one time only per OnReceive, and make sure the
processing of received data does not permit the message pump to execute
until after you have returned from OnReceive. Both of these steps are
necessary to avoid the possibility of OnReceive and Receive getting out of
sync.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Deaf CAsyncSocket on Windows Service.
    ... To read them out I need a buffer to ... Short packets at the sender are coalesced into longer packets. ... THe receiver says "I have this much buffer space" and the sender is free to send ... You get an OnReceive notification if there is input data to be read. ...
    (microsoft.public.vc.mfc)
  • Re: bad networking related lag in v2.6.22-rc2
    ... 1233 active connections openings ... 12 delayed acks further delayed because of locked socket ... 4867 packets directly queued to recvmsg prequeue. ... times receiver scheduled too late for direct processing ...
    (Linux-Kernel)
  • interpreting netstat -s
    ... 529092 duplicate acks ... what does the tcp output "embryonic connections ... 11772048 total packets received ... IP Multicast packets dropped due to no receiver ...
    (comp.unix.aix)
  • Re: Statistics Extraction
    ... 546 confirmed frames sent succesfully ... 549 packets sent successfully ... 105 transmits aborted due to rx ... packets dropped due to no receiver ...
    (comp.lang.perl.misc)
  • Re: Packet loss every 30.999 seconds
    ... Back to back test with no ethernet switch between two em interfaces, ... Receiver test application reports 3699 missed packets ... Receiver netstat -i: ...
    (freebsd-stable)