+
+sub _next_connection {
+ my $this = shift();
+
+ my $target;
+ my $n = $this->{modn};
+ my $i = $this->{modi};
+ if (!defined $n) {
+ $target = shift @{ $this->{queue} };
+ return undef if !defined $target;
+ } else {
+ while (1) {
+ $target = shift @{ $this->{queue} };
+ return undef if !defined $target;
+ my $h = _hash($target);
+ my $hmodn = $h % $n;
+ last if $hmodn == $i;
+ #$this->log("irspy", "'$target' hash $h % $n = $hmodn != $i");
+ }
+ }
+
+ die "oops -- target is undefined" if !defined $target;
+ return create ZOOM::IRSpy::Connection($this, $target, async => 1,
+ timeout => $this->{timeout});
+}
+
+
+sub _hash {
+ my($target) = @_;
+
+ my $n = 0;
+ foreach my $s (split //, $target) {
+ $n += ord($s);
+ }
+
+ return $n;