Hello:
   I'm not sure if this is related to your problem,
but I had a similar incident in the past, and it
turned out to be an unchecked buffer in my
OnDataAvailable event handler which caused an
overflow, which led to the TWSocket component not
realizing that the buffer had been emptied and
triggering the event again.

   Check to make sure that you are not overwriting
some data in your event handler due to a buffer overflow.

   -dZ.


>------- Original Message -------
>From    : Jake Traynham[mailto:[EMAIL PROTECTED]
>Sent    : 11/28/2007 4:24:15 PM
>To      : twsocket@elists.org
>Cc      : 
>Subject : RE: [twsocket] ASyncReceive and
wsoNoReceiveLoop
>
 >Hello all,

   I'm using ICS version 6.06 with Turbo C++ Explorer
2006.

   I had been fighting a problem where my
DataAvailable event was being 
called twice as many times (minus 1) as actually
needed.  Since I've 
been using the ICS components for many, many years
now, I obviously 
started looking to see if somehow I was calling
ProcessMessages again 
within the DataAvailable.  I couldn't find any where
that was true.

   I finally looked into the TWSocket sources to see
where DataAvailable 
was triggered from and to see if anything there would
make it act this 
way.  This is when I saw this wsoNoReceiveLoop thing
(which is 
apparently off by default).  Turning that option on
made my problem go away.

   My question is, what am I missing?  Either I don't
understand why you 
would *want* ASyncReceive to loop, or maybe I'm not
correctly reading in 
the data?  The component I'm working on receives
large amounts of data 
from a server in successive blocks.  From what I
observed, my 
DataAvailable event was being called twice minus one
more times than it 
needed to be.  For example, if the server sent 6
blocks of data, my 
DataAvailable event would get called 6 times to
receive all of the data, 
then get called 5 more times.  In the 5 extra times,
my code would 
attempt to do a Receive, which would return -1 along
with the "Would 
Block" winsock error.

   So, it seems that for every time ASyncReceive
looped, there would 
still be a message (FD_Read??) being put in the queue
to call it again, 
which would call my DataAvailable event again, but
there wouldn't be any 
data to read because ASyncReceive had already looped
to get all the 
data.  Again, am I missing something here?  Should
there have only been 
one FD_Read in the queue initially which would start
the ASyncReceive 
loop but some how the queue is getting corrupted (by
some call to 
ProcessMessages maybe) causing it to respond to the
FD_Read more than 
once.  Or should there be an FD_Read for every block
of data coming from 
the server, and if that's the case, why does
ASyncReceive loop?  Because 
if there is an FD_Read for every block of data, then
ASyncReceive and 
any DataAvailable events would be called multiple times.

Help! :)

Jake

-- 
Jake Traynham
Owner, CNS Plug-ins
 http://www.cnsplug-ins.com/ 
-- 
To unsubscribe or change your settings for TWSocket
mailing list
please goto 
http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket

Visit our website at  http://www.overbyte.be 


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to