user3166379
user3166379

Reputation: 331

Delphi. Thread methods access through Thread's handle and (or ) ID

I'm developing little client-server based application on Delphi, using Winsock 1.1 Server: When client trying to connect via TCP protocol, I create for him new socket and a thread, to work with it. I create new threads with CreateThread() procedure. So for each client I have socket + thread I store threads handles and IDs in array, that I can access at any time. But I dont understand how can I call thread methods by using it's handle and(or) ID.

Upvotes: 0

Views: 730

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 596497

You are not creating any thread objects so there are no methods to call. Derive a class from TThread instead of calling CreateThread() directly, then you can create a new thread object for each client, store the object pointers in a list, and call methods on those objects when needed. You can then give your class a queue member to hold pending data, and override the virtual Execute() method to process that queue as needed.

Upvotes: 1

Related Questions