Re: [twsocket] 100% CPU usage if data is not processed immediately

2007-09-27 Thread Olivier Sannier
Francois Piette wrote: > Designing a system having in mind variable length data will result in a > better system. Variable length can do fixed length easily, not the reverse. > It is variable length, but I'm only writing the socket layer. Basically, I'm given data in an unknown form and being a

Re: [twsocket] 100% CPU usage if data is not processed immediately

2007-09-27 Thread Francois Piette
> > See http://wiki.overbyte.be/wiki/index.php/Sending_and_receiving_data > > that discusses some possible data transfer modes. > Thanks for that link. My code is for a transport layer that should not > make any assumption on what is transferred, so binary mode without any > line buffering is the

Re: [twsocket] 100% CPU usage if data is not processed immediately

2007-09-27 Thread Olivier Sannier
Wilfried Mestdagh wrote: > Hello Olivier, > > >> I can't use LineMode, what is transferred is purely binary. >> > > See http://wiki.overbyte.be/wiki/index.php/Sending_and_receiving_data > that discusses some possible data transfer modes. > Thanks for that link. My code is for a transpor

Re: [twsocket] 100% CPU usage if data is not processed immediately

2007-09-27 Thread Wilfried Mestdagh
Hello Olivier, > I can't use LineMode, what is transferred is purely binary. See http://wiki.overbyte.be/wiki/index.php/Sending_and_receiving_data that discusses some possible data transfer modes. > buffer and rely on the one from the API itself. > I tried it, it works fine, but is it be a "nice

Re: [twsocket] 100% CPU usage if data is not processed immediately

2007-09-27 Thread Olivier Sannier
Hi, Wilfried Mestdagh wrote: > 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. Th

Re: [twsocket] 100% CPU usage if data is not processed immediately

2007-09-26 Thread Arno Garrels
Olivier Sannier wrote: > 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? You have to use some buffer, its size depends on your protocol. I.e. the client could send the data length as the first byt

Re: [twsocket] 100% CPU usage if data is not processed immediately

2007-09-26 Thread Wilfried Mestdagh
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 certa

Re: [twsocket] 100% CPU usage if data is not processed immediately

2007-09-26 Thread Arno Garrels
Olivier Sannier wrote: > > if bMore then > Sleep(1); { to avoid 100% CPU } > > At line 4231, right after the end of the try except block. > To me this has little to no effect as the sleep is only done when > bMore is True. > What do you think of this proposal? That would slo

Re: [twsocket] 100% CPU usage if data is not processed immediately

2007-09-26 Thread Olivier Sannier
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 > OnDa

Re: [twsocket] 100% CPU usage if data is not processed immediately

2007-09-26 Thread Wilfried Mestdagh
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 OnDataAvail

[twsocket] 100% CPU usage if data is not processed immediately

2007-09-26 Thread Olivier Sannier
Hi, I'm using TWSocketS with a custom TWSocket derived class called TMyClientSocket to implement a TCP/IP server. I have overridden TriggerDataAvailable in TMyClientSocket in such a way: function TROAsyncSuperTcpServerSocketClient.TriggerDataAvailable( Error: Word): Boolean; begin inherited