Re: SocketFactory

Torsten Foertsch <[email protected]>
Newsgroups gmane.comp.lang.perl.poe
Message-ID <[email protected]>
On Tue 16 Sep 2008, Martijn van Beers wrote:
> > is it possible to use one SocketFactory to connect to multiple
> > remote addresses, one at a time?
> >
> > I know I can use a SocketFactory object to connect to one server
> > and then throw it away, create another one to connect to the next
> > server and so on. But that would mean the wheel ID would change
> > every time, right? I'd like if that ID could be constant. Hence the
> > idea of reusing an existing SF wheel.
>
> You should probably explain what you are really trying to do, because
> if you think you need the wheel ID to be predictable, you are doing
> something wrong.

something like that:

my @try_ips=("1.2.3.4", "5.6.67.8", ...);

my $sf=SocketFactory->new( RemoteAddress=>shift $try_ips, ... );

my $context{$sf->ID}=[\@try_ips, $sf];

sub OnFailureEvent {
  my $ctx=$context{$_[ARG3]};

  $ctx->[1]->try_next( RemoteAddress=>shift @{$ctx->[0]} );
}

So I don't want the ID to be predictable. I want to reuse an SF object.

Don't worry, I can do that this way:

sub OnFailureEvent {
  my $ctx=delete $context{$_[ARG3]};

  $ctx->[1]=SF->new( RemoteAddress=>shift @{$ctx->[0]} );
  $context{$ctx->[1]->ID}=$ctx;
}

Torsten

--
Need professional mod_perl support?
Just hire me: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.