Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 May : Passing a connection reference in PostThreadMessage
| Subject: | Passing a connection reference in PostThreadMessage |
| Posted by: | "Marais" (mara..@x.y) |
| Date: | Tue, 15 May 2007 13:55:41 GMT |
I'm using TIdTCPServer to build an application which accepts multiple
connections. Each client, after connecting, is to receive data from time to
time sent by the server. Some data will go to one client, some to another.
Commands from the clients tell the server which data they are interested in
receiving.
My model is that the command handlers use PostThreadMessage to tell the main
thread when a client has expressed an interest in receiving updates to which
data.
I was wondering how best to encode something identifying the client in the
PostThreadMessage call. There appears to be a longword parameter (is this
what lParam means?), so presumably I could use this to send a pointer to the
connection. I could then dereference this in the main thread and use methods
like Connection.writeln to send data to the appropriate client.
This seems rather clumsy. I'm afraid that my ignorance of pointers is
showing here. Is there a canonical way of doing this?
Peter