| AnyEvent::TFTPd - Trivial File Transfer Protocol daemon |
AnyEvent::TFTPd - Trivial File Transfer Protocol daemon
0.10
This module handles TFTP request in an AnyEvent environment.
package My::AnyEvent::Connection; use Moose; extends 'AnyEvent::TFTPd::Connection';
sub _build_filehandle { my $self = shift; my $file = $self->file;
# ...
return $filehandle;
}
1;
package main;
my $tftpd = AnyEvent::TFTPd->new( address => 'localhost', port => 69, connection_class => 'My::AnyEvent::Connection', max_connections => 100, )->setup or die $@;
Holds the address this server should bind to. Default is "127.0.0.1".
Holds the default port this server should listen to. Default is 69.
This string holds the classname where the connection objects should be constructed from. The default the AnyEvent::TFTPd::Connection manpage class is quite useless without subclassing it. See SYNOPSIS for more details.
The max concurrent connections this object can handle. Used inside on_connect() to decide if a new connection should be establised or not.
Setting this to zero (the default) means that the server should handle unlimited connections.
$connection_obj = $self->get_connection(peername); $connection_obj = $self->add_connection($connection_obj); @connections = $self->get_all_connections;
This attribute holds a hash-ref, where the keys are peername() of the
connections, and the values point to the AnyEvent::TFTPd::Connection manpage objects.
Use the delegated methods listed above to access this attribute.
$io_socket_inet = $self->socket; $packed = $self->peername;
This attribute holds an instance of the AnyEvent::Handle::UDP manpage, which handles the methods listed above.
This method will prepare the handle/socket for incoming connections.
It will return c<$self> on success and 0 on failure. Check $@ for
a full error message on failure.
Return value $self allows you to chain new() and setup().
This hook is called each time data is received from a peer host. It will parse the datagram received and act accordingly.
This method returns a new the AnyEvent::TFTPd::Connection manpage object for a new connection. This method is called when either a RRQ/WRQ opcode is received in on_read().
This method might skip these steps if no more connections are available. This is computed by comparing the number of connections and max_connections.
This hook is called from the handler, when something unexpected has happened. See the AnyEvent::Handle manpage for details.
Copyright 2007 Jan Henning Thorsen, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Jan Henning Thorsen jhthorsen at cpan.org
| AnyEvent::TFTPd - Trivial File Transfer Protocol daemon |