On Fri, Jul 21, 2000 at 04:35:57PM -0400, Paul Jarc wrote:
> [EMAIL PROTECTED] writes:
> > On Fri, Jul 21, 2000 at 03:10:58PM -0500, Austad, Jay wrote:
> > > Instead of having qmqpc picking the first available server, I would like it
> > > to load balance between all servers I have listed as QMQP servers.
> ...
> > > This way, "i" will be a random number from 0 to (servers.len-1).
> >
> > Almost. Note that 'i' has to point to the start of the \0 terminated
> > string that 'j' is currently scanning. servers.s is a series of \0
> > terminated strings. You need to do some work to make sure that i, is
> > pointing that the start of the string that j randomizes into.
>
> Also note that if you choose one at random every time, you just might
> choose the same one, which happens to be down, every time. It'd be
> better to rotate the list by a random number of entries, and then step
> through it normally.
I think he as trying to randomize the start point and cycle thru the
list as qmqpc does now. So even if he hits the same starting point,
it'll still find a good server. Leastwise that's what I was originally
trying to show with the posted code-fragment.
Regards.