My code creates several TidTCPClients and then adds references to them in a TThreadList.
I was hoping to send commands to all of them by then using
for I := 0 to (NumClients - 1) do
begin
ClientList[I].IOHandler.WriteLn('Whatever');
end;
(that's obviously only a small part of the code).
However I'm getting two errors:
[DCC Error] Client.pas(261): E2149 Class does not have a default property
[DCC Error] Client.pas(262): E2233 Property 'IOHandler' inaccessible here
and after a brief read of This I'm none the wiser about how to do this, but definitely beginning to think that I'm on the wrong track entirely.
Can anyone point me in the right direction?
See doc how to operate TThreadList
. You also need to type cast the TidTCPClient
objects in the list since it only contains untyped pointers.
var
list: TList;
...
list := ClientList.LockList;
try
for I := 0 to list.Count - 1 do
begin
TidTCPClient(list[I]).IOHandler.WriteLn('Whatever');
end;
finally
ClientList.UnlockList;
end;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.