Hello Olivier,

> That's what I thought, but then again, this means I need to have a
> buffer of my own, and I have no idea which size it should be. 1k, 10k, more?

Yes. TWSocket is designed to buffer incoming data for you if you use
LineMode. That is when you have your data terminated with a certain
character (or a string of characters). If you dont use LineMode then yes
you have to buffer on your own.

> I know that, but with 100%CPU usage, the handling of messages is stopped
> anyway as well as no other thread will be able to take control. Well, 
> maybe on a multi core, but not on single core machines.

Agree, but there is also a componentOptions property wsoNoReceiveLoop
which will fire OnDataAvailable again using a custom message handler. In
that case message pump stay working.

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

Wednesday, September 26, 2007, 15:38, Olivier Sannier wrote:

> Wilfried Mestdagh wrote:
>> Hello Olivier,
>>
>>   
>>> The NotifyDataAvailable sets a flag in an object associated to the
>>> client socket that will then read the available bytes. But it will not
>>> do so immediately
>>>     
>>
>> That's the problem. You have to read "all" available data "In" the
>> OnDataAvailable event. If you do not then OnDataAvailable will fire
>> again in a loop where you must receive the rest of the data, or if you
>> set wsoNoReceiveLoop in ComponentOptions property then it is fired using
>> a custom message handler.
>>   
> That's what I thought, but then again, this means I need to have a 
> buffer of my own, and I have no idea which size it should be. 1k, 10k, more?

>> So the Sleep is not needed. Also it is a bad idea because if there is
>> high speed data received and more than will be received in the event it
>> will delay the reception of data during a time slice (10..20 millisec
>> depending on the OS) and will grow winsock internal receive buffer,
>> because during the Sleep the message pump is not working.
>>   
> I know that, but with 100%CPU usage, the handling of messages is stopped
> anyway as well as no other thread will be able to take control. Well, 
> maybe on a multi core, but not on single core machines.

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

Reply via email to