[fpc-pascal] How to close TInetServer without except?

Ludo Brands ludo.brands at free.fr
Mon May 6 20:10:56 CEST 2013

On 05/06/2013 07:17 AM, silvioprog wrote:

> Ludo, I'm almost by completing the units in this link:
> https://bitbucket.org/silvioprog/tcpipcomp (this repository is temporary)
> The current code (I'm updating it daily) in these units is good? I'm
> open to suggestions, and we can change whatever it takes.
> I want to send these units to the Free Pascal team and a package to the
> Lazarus team.
> Sorry for my English please.

In TTcpIpClientSocketThread.Execute you do a read followed by a select.
The logic is: first select then read when something is available.

The sleep(0) is not needed. Select suspends already the thread when waiting.

          VTimeVal.tv_sec := 0;
          VTimeVal.tv_usec := 100;
That is 100 microseconds which is very short. On top of that, when the
timeout expires, you test if FDisconnectClient is set and, if not set,
you do the read immediately again. The read is therefor again hanging
until something comes in.

Watch out for Synchronize(@DoReceive) in a recv loop. That is going to
drag down your performance considerably.


More information about the fpc-pascal mailing list