Re: How to have server send to multiple clients?

Giganews Newsgroups
Subject: Re: How to have server send to multiple clients?
Posted by:  Remy Lebeau (TeamB) (gambit…@yahoo.com)
Date: Tue, 9 Sep 2003

"John Herbster (TeamB)" <herb-sci1_at_sbcglobal.net> wrote in message
news:C4CA05B53D7EE240herb-sci1_at_sbcglobal.net...

> What would be the most straight-forward Indy solution
> to this client problem be?

Using a TIdTCPClient, call ReadLn() in a separate thread.  Otherwise, call
IOHandler.Readable() in a timer and then call ReadLn() if Readable() returns
true.  Either way, when the data eventually comes through, you can pass the
string to your previous handling code as before.

> And I need to create a new TCP server that can spit out the
> same line of data to each of a few clients every half second or so.

You do not need to spawn multiple servers for that.  A single server can
service multiple clients at a time, and when broadcasting a data packet to
multiple clients, simple loop through the available client connections
sending the data to each one.  TIdTCPServer has a Threads property for
accesing the individual connections.

> What do you recommend for this server?  Should I use a
> thread for each connected client?

Indy servers already do that anyway.

Gambit

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system http://www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03

Replies

In response to

How to have server send to multiple clients? posted by John Herbster (TeamB) on Tue, 9 Sep 2003