How do I broadcast to all connected clients of a tidtcpserver?

Giganews Newsgroups
Subject:How do I broadcast to all connected clients of a tidtcpserver?
Posted by: Ren Baker
Date:Fri, 29 May 2009

I am new to using Indy components, and intermediate with Delphi.  I am experimenting with a Sockets-based Client/Server type of application wherein the "Client" software will function as a "Remote Control" for the server application.  So, in effect, if the "Client" application sends a command, the server will execute certain functions on it's own, and respond with confirmation.  This isn't a C/S app in the classic sense, the client's only function is to be a remote controller for the server application.

I downloaded some sample applications that are based on building a chat-type of server, and I have been successful in all the functions that are initiated by the client software piece.  However, I also need to have a way for the server to send information down to the clients on a periodic basis - such as a timecode, where I would "push" a timecode and status message down to the client each second.

Since there may be more than one client connected, I need to have a way to push this data to all clients simultaneously.

I have figured out how to push the same response data to all clients when prompted by any one of them - i.e. client 1 sends a command and all clients get updated with the same result.  But I don't want to have a timer function running on the client side because that's just not a clean or proper way to do it.

I would imagine there must be an easy way to get the TIDTCPSERVER component to push data to all connected clients.  Any assistance would be appreciated.

Replies