Hello Jake,

> However, I would like this code to work/receive as fast as possible. The
> comment in the code where wsoNoReceiveLoop was introduced says that this
> option gives "lower resource usage with really fast LAN and large 
> transfers".  Does that mean it's faster, or just uses less memory?

In fact it is a little slower when you set wsoNoReceiveLoop.

> 1. Use GetRcvdCount to determine how much data Receive can return and
> read in that much data. (There is a comment in the code that says this
> function can't be trusted on NT....)

Correcect it is unreliable on NT. I never used it because of this but
never used it in later OS also. So I dont know if it is still unreliable
in other OS.

> Or would winsock buffer the data in the background while I'm
> processing data and send me a chunk of data much larger than what can
> fit in an ethernet packet?

Yes, it is depending the sending speed (lan speed), receiving speed.

> 3. Put a loop in my DataAvailable event that will do a Receive until I
> get -1 back.  This would probably be the easiest to implement for me.

No never do that. Don't set wsoReceiveLoop. If something is still (or
again) in receiving winsock buffer when you leave OnDataAvailable then
it will trigger again in a loop.

> All in all, speed is my main interest here.  I want to read in all the
> data the server is sending me as fast as possible.

- if possible move the data direcly where it belong, not copy it first in
  a buffer as you do now. If you have to buffer it in between for some
  reason make it as large as possible (make a little test case to see
  how large receiving packets will be in a real world test).
- if you move direcly where it belong then you have to receive only what
  you need of course. but no worry OnDataAvailable will trigger again
  immediatly.

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

Tuesday, December 4, 2007, 20:31, Jake Traynham wrote:

> Hi Arno,

>    Thanks for the insight.  More questions below:

> Arno Garrels wrote:
>> Jake Traynham wrote:
>> 
>>>    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. 
>> 
>> That's correct, it's the call to WSocket_Synchronized_ioctlsocket() 
>> with option FIONREAD that causes winsock to send the extra FD_READ
>> message.
>> So nothing is corrupted, simply add wsoNoReceiveLoop to the options
>> to get rid of that behaviour.
>> Winsock will always send subsequent FD_Read messages after any call
>> to one of the receive functions if there is still data available. 
>> 

> Okay, so let me make sure I understand correctly. I call Receive in my
> DataAvailable event. If I don't request the entire amount of available
> data, winsock automatically throws another FD_Read message in the queue?
>   So, that means that if I'm going to read in 1024 bytes at a time, I 
> should set wsoNoReceiveLoop so that I don't get extra calls to 
> DataAvailable.  This makes sense and is what my code is currently doing.

> However, I would like this code to work/receive as fast as possible. The
> comment in the code where wsoNoReceiveLoop was introduced says that this
> option gives "lower resource usage with really fast LAN and large 
> transfers".  Does that mean it's faster, or just uses less memory? 
> Would it be faster to read in all available data in each call to my 
> DataAvailable event (which, if I understand correctly would not trigger
> the extra FD_Read events)?  If so, what would be the best approach to 
> that?  Seems to me there would be three options:

> 1. Use GetRcvdCount to determine how much data Receive can return and 
> read in that much data. (There is a comment in the code that says this
> function can't be trusted on NT....)

> 2. When I call Receive, specify a large enough buffer to read in 
> whatever might be there.  I'm currently using a 1024 byte buffer.  Would
> increasing that to something over 1460 be sufficient?  Or would winsock
> buffer the data in the background while I'm processing data and send me
> a chunk of data much larger than what can fit in an ethernet packet?

> 3. Put a loop in my DataAvailable event that will do a Receive until I
> get -1 back.  This would probably be the easiest to implement for me.

> All in all, speed is my main interest here.  I want to read in all the
> data the server is sending me as fast as possible.  Thanks for any 
> pointers you or anyone else on the list can give me.

> 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

Reply via email to