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

Ludo Brands ludo.brands at free.fr
Sat May 4 07:45:54 CEST 2013


On 05/03/2013 05:57 PM, silvioprog wrote:

> 
> Could you give me an example in practice? Theoretically I understand,
> but I don't know do in practice. :/
> 
> Now, TTcpIpServer is working well. The new problem is: when I close the
> server with one or more clients connected, I got a memory leak.
> 

Take a look at TBlockSocket.InternalCanRead and TBlockSocket.CanRead in
synapse on how to set up select correctly. Then do something like

repeat
  if Socket.CanRead(timeout) then
    begin
    insock:=Socket.Accept;
    if insock<>-1 then
      //start working with insock
    else
      //deal with error
    end;
until ThreadTerminated;

Ludo



More information about the fpc-pascal mailing list