Chris Williams

NAME

POE::Component::SmokeBox::Recent::FTP - an extremely minimal FTP client

SYNOPSIS

  # Obtain the RECENT file from a given CPAN mirror.
  use strict;
  use warnings;
  use File::Spec;
  use POE qw(Component::SmokeBox::Recent::FTP);

  my $site = shift || die "You must provide a site parameter\n";
  my $path = shift || '/';

  POE::Session->create(
     package_states => [
        main => [qw(_start ftp_sockerr ftp_error ftp_data ftp_done)],
     ]
  );

  $poe_kernel->run();
  exit 0;

  sub _start {
    POE::Component::SmokeBox::Recent::FTP->spawn(
        address => $site,
        path    => File::Spec::Unix->catfile( $path, 'RECENT' )
    );
    return;
  }

  sub ftp_sockerr {
    warn join ' ', @_[ARG0..$#_];
    return;
  }

  sub ftp_error {
    warn "Error: '" . $_[ARG0] . "'\n";
    return;
  }

  sub ftp_data {
    print $_[ARG0], "\n";
    return;
  }

  sub ftp_done {
    warn "Transfer complete\n";
    return;
  }

DESCRIPTION

POE::Component::SmokeBox::Recent::FTP is the small helper module used by POE::Component::SmokeBox::Recent to do FTP client duties.

It only implements an ascii type passive FTP RETR.

CONSTRUCTOR

spawn

Takes a number of parameters:

  'address', the hostname/address of the FTP site to connect to, mandatory;
  'path', the path to the file you want to retrieve from the site, mandatory;
  'session', optional if the poco is spawned from within another session;
  'prefix', specify an event prefix other than the default of 'ftp';

OUTPUT EVENTS

The component sends the following events. If you have changed the prefixi option in spawn then substitute ftp with the event prefix that you specified.

ftp_sockerr

Generated if there is a problem connecting to the given FTP host/address. ARG0 contains the name of the operation that failed. ARG1 and ARG2 hold numeric and string values for $!, respectively.

ftp_error

Generated if there is an FTP error. ARG0 contains the error sent by the server.

ftp_data

One of these events will be emitted for each line of file you have specified to be retrieved. ARG0 contains that line.

ftp_done

Emitted when the transfer has finished.

AUTHOR

Chris BinGOs Williams <chris@bingosnet.co.uk>

LICENSE

Copyright © Chris Williams

This module may be used, modified, and distributed under the same terms as Perl itself. Please see the license that came with your Perl distribution for details.