AnyEvent-FCP

 view release on metacpan or  search on metacpan

FCP.pm  view on Meta::CPAN


=item port => $portnumber

The port number of the FCP port. Default is C<$ENV{FREDPORT}> or C<9481>.

=item timeout => $seconds

The timeout, in seconds, after which a connection error is assumed when
there is no activity. Default is C<7200>, i.e. two hours.

=item keepalive => $seconds

The interval, in seconds, at which keepalive messages will be
sent. Default is C<540>, i.e. nine minutes.

These keepalive messages are useful both to detect that a connection is
no longer working and to keep any (home) routers from expiring their
masquerading entry.

=item on_eof => $callback->($fcp)

Invoked when the underlying L<AnyEvent::Handle> signals EOF, currently
regardless of whether the EOF was expected or not.

=item on_error => $callback->($fcp, $message)

FCP.pm  view on Meta::CPAN


sub new {
   my $class = shift;

   my $rand = join "", map chr 0x21 + rand 94, 1..40; # ~ 262 bits entropy

   my $self = bless {
      host       => $ENV{FREDHOST} || "127.0.0.1",
      port       => $ENV{FREDPORT} || 9481,
      timeout    => 3600 * 2,
      keepalive  => 9 * 60,
      name       => time.rand.rand.rand, # lame
      @_,
      queue      => [],
      req        => {},
      prefix     => "..:aefcpid:$rand:",
      idseq      => "a0",
   }, $class;

   {
      Scalar::Util::weaken (my $self = $self);

      $self->{kw} = AE::timer $self->{keepalive}, $self->{keepalive}, sub {
         $self->{hdl}->push_write ("\n");
      };

      our $ENDMESSAGE = qr<\012(EndMessage|Data)\012>;

      # these are declared here for performance reasons
      my ($k, $v, $type);
      my $rdata;
         
      my $on_read = sub {

README  view on Meta::CPAN


        port => $portnumber
            The port number of the FCP port. Default is $ENV{FREDPORT} or
            9481.

        timeout => $seconds
            The timeout, in seconds, after which a connection error is
            assumed when there is no activity. Default is 7200, i.e. two
            hours.

        keepalive => $seconds
            The interval, in seconds, at which keepalive messages will be
            sent. Default is 540, i.e. nine minutes.

            These keepalive messages are useful both to detect that a
            connection is no longer working and to keep any (home) routers
            from expiring their masquerading entry.

        on_eof => $callback->($fcp)
            Invoked when the underlying AnyEvent::Handle signals EOF,
            currently regardless of whether the EOF was expected or not.

        on_error => $callback->($fcp, $message)
            Invoked on any (fatal) errors, such as unexpected connection
            close. The callback receives the FCP object and a textual error



( run in 0.926 second using v1.01-cache-2.11-cpan-df04353d9ac )