Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Dec : Re: How to stop a Tid(Cmd)TCPServer while clients are connected?

www.cryer.info
Managed Newsgroup Archive

Re: How to stop a Tid(Cmd)TCPServer while clients are connected?

Subject:Re: How to stop a Tid(Cmd)TCPServer while clients are connected?
Posted by:"Chris Ueberall" (cuebera..@web.de)
Date:5 Dec 2007 04:04:44

Remy Lebeau (TeamB) wrote:

>
> "Chris Ueberall" <CUeberall@web.de> wrote in message news:4755f37c$1@newsgroups.borland.com...
>
> > I used Contexts.LockList/UnlockList surrounded by try/finally.
>
> But what were you doing in between the LockList() and UnlockList() calls?


I'm updating some GUI controls (a TShape [shpClientConnected] and a TMemo [memClients]):

  contexts  := FCmdServer.Contexts.LockList;
  try
    memClients.Clear;
    if contexts.Count > 0 then begin
      shpClientConnected.Brush.Color  := clGreen;

      for i := 0 to contexts.Count - 1 do begin
        if (TidContext(contexts[i]).Connection <> nil)
            and (TidContext(contexts[i]).Connection.Socket <> nil)
            and (TidContext(contexts[i]).Connection.Socket.Binding <> nil) then begin
          memClients.Lines.Add(TidContext(contexts[i]).Connection.Socket.Binding.PeerIP);
          end
        else begin
          Beep;
        end;
      end;
      end
    else begin
      shpClientConnected.Brush.Color  := clGray;
    end;
  finally
    FCmdServer.Contexts.UnlockList;
  end;

--
Chris Ueberall;

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive