Lee wrote:
> Hi,
>
> I'm trying to write a TCP server with synapse blocking sockets.
>
> I created a TThread decendent class to listen for incoming requests and
> it works ok, except it looks like it executes in the main thread because
>    the console no longer responds when my class is executed and a
> blocking socket is created inside it.
>
> var
> Serv : TAstServer;
> sRead: string;
> begin
>
>     Serv := TAstServer.Create(true);
>     Serv.Execute;
>     try
>     while (true) do
>        begin
>        ReadLn(sRead);
>        if (sRead = 'quit') then
>           begin
>           Serv.Terminate;
>           break;
>           end;
>        end;
>     finally;
>        Serv.free;
>        end;
> end;
>
> Execution never goes past "Serv.Execute" above.

"Serv := TAstServer.Create(true);" creates a suspended thread, and needs 
Serv.Resume to start.  Don't use Serv.Execute, unless you want to use it as 
a normal non-threaded routine.

If you want to start the thread immediatly use:

  Serv := TAstServer.Create(false);


Thanks!

--
Al

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to