Re:Telnet Server "Shutting Down" message
Quote
Richard Owen <metrixsoftw...@hotmail.com> wrote in message news:3d8fb6d5$1@newsgroups.borland.com...
> I am using the TidTelnetServer... Indy 9.0
> What I am aiming for is too "broadcast" a message to all connected clients
> (I am using the built in Telnet client of Windows XP)...
> For example: when a user logs in I would like to send too all other
> connected users "George has logged in"
> My worry is that each Telnet connection is in a thread and I need to get
> each thread to do a Connection.Writeln('George has connected');
> Is there some helper function that can do this?
> Do I need to maintain an external TThreadList of connections or is there
> already one available?
> What threading issues do I have to worry about?
I seem to remember that there is a 'bindings' property that allows you to
iterate the connections. I am fairly sure, (that's code for 'I haven't tried
it myself'), that there should be no inherent problem with a write call from
the thread that created the TidTCPserver. The snag is that the individual
connection threads can also asynchronously write - presumably they write
telnet prompts, echo chars. from the clients and send data in response to
commands. I suggest a critical section around all these write calls, CS's
that you should acquire in the parent thread before issuing each broadcast
write. Also, there is the problem of how you/Indy maintain your
connections. The bindings list may change while you iterate it as users log
in & disconnect. You have to take care here, and it may be that you
cannot avoid an occasional AV or other error during this process - trap &
dump.
Rgds,
Martin