04-29-2022, 01:07 AM
Thanks for the quick reply -
The procedure in question is:
frm_server is a reference to a form, skt_srv is a TIdTCPServer dropped onto the form.
In the try section I already changed the TIdPeerThread to the TIdContext.
Based on context from when this procedure gets called. Looks like a list of clients are kept, then a string is being sent to a specific client - and if that fails, stop that client's connection.
Searching the entire project, it appears this is the only spot that an TIdPeerThread.Stop exists - based on a search of files in project for ").Stop;". I did find one .Free.
So based on your post - that would be replaced with "TIdYarnOfThread(TIdContext(List.Items[index]).Yarn).Thread.Stop();". - for direct update.
Addressing why it is being done this way, I don't know. I'm taking code that I received 10+ years ago, trying to get it to compile and run now so that I can add a minor update to it for a person who still uses the application.
I'm not opposed to doing it the right way.
Seth
The procedure in question is:
Code:
procedure sendto_one (index : integer; line : string);
var List : Tlist;
begin
List := frm_server.skt_srv.Contexts.LockList;
try
try
TIdContext(List.Items[index]).Connection.IOHandler.WriteLn(Line);
except
TIdPeerThread(List.Items[index]).Stop;
end;
finally
frm_server.skt_srv.Contexts.UnlockList
end
end;
In the try section I already changed the TIdPeerThread to the TIdContext.
Based on context from when this procedure gets called. Looks like a list of clients are kept, then a string is being sent to a specific client - and if that fails, stop that client's connection.
Searching the entire project, it appears this is the only spot that an TIdPeerThread.Stop exists - based on a search of files in project for ").Stop;". I did find one .Free.
So based on your post - that would be replaced with "TIdYarnOfThread(TIdContext(List.Items[index]).Yarn).Thread.Stop();". - for direct update.
Addressing why it is being done this way, I don't know. I'm taking code that I received 10+ years ago, trying to get it to compile and run now so that I can add a minor update to it for a person who still uses the application.
I'm not opposed to doing it the right way.
Seth