Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 May : Re: Broadcasting messages with Indy
| Subject: | Re: Broadcasting messages with Indy |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Thu, 18 May 2006 10:58:32 |
"David Hooker" <david.d.hooker@gmail.com> wrote in message
news:446c12b2@newsgroups.borland.com...
> Is there a way to send the same message to many other computers in
> parallel using Indy without requiring a thread per connection?
UDP supports broadcasting over a subnet. TCP does not support any kind of
broadcasting at all.
> For example, say I have an enourmous array of connections and I want
> to send the same message to them all (but all of these connections are to
> other addresses on the Internet, so I would expect that UDP broadcasts
> wouldn't work). I would like to send all messages at the same time.
You won't be able to send them simultaneously without using threads, as you
will have to copy the message to each computer individually. That is simply
the way TCP works. Otherwise, you will have to use UDP, and deal with the
potential problems that UDP has (lost packets, blocked packets, packets
arriving in a different order than they were sent, etc).
> Using one thread to send all the messages seems to require that all
> messages be sent in series.
Correct.
> On the other hand, requiring one or two threads per connection
Why would you think that you need multiple threads for every connection?
You don't. What you can do, however, is run a number of threads that each
have their individual list of connections to send to. In other words, for
100 connections, you could have 10 threads sending to 10 connections each.
You won't be able to send data to all 100 connections simultaneously, but
you can send to 10 simultaneously, and you would only be serializing 10
connections per thread instead of serializing all 100.
Gambit
none