[twsocket] Application freezing when getting data

Stephen Williams SWilliams@fm.optus.net.au
Wed, 28 Jun 2000 09:06:18 +1000


How are you doing the actual send?  As one call to Send?  If so, then your
application is locked because it is busy copying 2MB of data to the internal
buffers of the TWSocket component which are then copied to the Winsock
buffers.

Break it into smaller chunks.  Say 4KB for example.  I recently wrote a
TWSocket descendant that can send and/or receive a stream of any size in
user-definable chunks.  The test application never locked up during the send
or receive, even on very large files.  It can even send and receive
different streams at the same time.

The basis of the code was to send a small header with info like the size of
the stream, etc.  In the OnDataSent event, the first chunk of data was sent.
Subsequent chunks were sent in each trigger of the OnDataSent event until
the entire stream had been sent.

Steve 'Sly' Williams
IT Development
Cable & Wireless Optus Outsourcing Services
swilliams@fm.optus.net.au
------------------------------------------------------------
"Programming is an art form that fights back." -Unknown
------------------------------------------------------------

> I've got a client an a server application both
> using TWSocket. On the server I can paint on a
> TImage and save it to a TStringStream and push
> it through an UUEncoder. Every line is now sent
> to the client. There every line is decoded back
> into a stream and then load back into a TImage.
> 
> If I transfer the image in black/white ~40 KBytes
> it is slow but it works... 
> but on high-color and a resolution of 1024x768 it
> is ~2 MBytes and the Application freezes.
> If I insert a Sleep(100) before sending it works
> but then it takes more than 5 minutes on a 10 MBit
> ethernet.
> 
> My questions about that:
> 1.  Is there any possibility to make it faster
>     (transfering it binary - but how?)
> 2.  How do it the big *professional* applications
>     (like VNC; there are the souces available but
>     I can't programm in c++)
> 3.  When a big server is sending for example HTML
>     files a small browser client does not freeze 
>     - but why my client? 
>     (has TCP/IP not an overload protection?)