通过获取tcpserver.getonlinecontextlist来得到在线列表

procedure TfrmMain.btn_refreshClick(Sender: TObject);
var
  lvList:TList;
  i: Integer;
  lvClient:TMyClientContext;
  lvItem:TListItem;
begin
  lstClientINfo.Items.Clear;
  lvList:=TList.Create;
  try
   FTcpServer.getOnlineContextList(lvList);
   for i := 0 to lvList.Count - 1 do
    begin
      lvClient := TMyClientContext(lvList[i]);
      lvItem := lstClientINfo.Items.Add;
      lvItem.Caption :=IntToStr(i+1);
      try
      lvItem.SubItems.Add(TChatSession(lvClient.Data).UserID);
      except on E: Exception do
      lvItem.SubItems.Add(‘未登录‘);
      end;
       try
      lvItem.SubItems.Add(TChatSession(lvClient.Data).UserMac);
      except on E: Exception do
      lvItem.SubItems.Add(‘未知‘);
      end;
//      lvItem.SubItems.Add(‘‘);
      lvItem.SubItems.Add(lvClient.RemoteAddr);
      lvItem.SubItems.Add(IntToStr(lvClient.RemotePort));
//      if TChatSession(lvClient.Data).UserID<>‘‘ then
//
//      lvItem.SubItems.Add(TChatSession(lvClient.Data).UserID)
//      else
//      lvItem.SubItems.Add(‘‘);
      lvItem.SubItems.Add(IntToStr(lvClient.SocketHandle));
      lvItem.SubItems.Add(lvClient.StateINfo);
    end;
  finally
    lvList.Free;
  end;
end;
原文:http://www.cnblogs.com/diocp/p/5843362.html