Board index » delphi » Indy TCP Server - sending data to all connected?

Indy TCP Server - sending data to all connected?

Hello,

I'm running a TIdTCPServer, which has clients connecting and then they're
running in OnExecute (as opposed to command handlers, but I could change to
command handlers if needed).
In the main thread, I calculate some data, and I want to send it to all the
current clients which are connected. But I also wish to clear the stream
containing the data as soon as it has been sent to all connections.
How do I notify my threads that I have some data ready for them, and how do
I know when all data has been sent (or any other progress status).
I hope this is explained clear enough.

Thanks

Koen

 

Re:Indy TCP Server - sending data to all connected?


Quote
> In the main thread, I calculate some data, and I want to send it to all
the
> current clients which are connected. But I also wish to clear the stream
> containing the data as soon as it has been sent to all connections.
> How do I notify my threads that I have some data ready for them, and how
do
> I know when all data has been sent (or any other progress status).

* to know who is connected use LockList
* to tell the clients something is incoming just send an identifier like
connection.writeln('incoming');  ... then send the data / stream / whatever
* You know the data has been sent when its sent :-)   ... in other words, if
you do for example;

AThread.connection.WriteStream

 then as soon as it comes out of that line u know its sent.

hth,

/A.

Other Threads