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;


Changing my code to the following seems to fix my problem:

var
sRead: string;
begin
  TAstServer.Create(false);
   try
   while (true) do
      begin
      ReadLn(sRead);
      if (sRead = 'quit') then
         break;
      end;


end.


--

Warm Regards,

Lee

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

Reply via email to