Asyncore - basic infrastracture for asynchronous socket services
use Asyncore; use base qw( Asyncore::Dispatcher ); my $server = Asyncore::Dispatcher->new(); $server->create_socket(); $server->bind($port) $server->listen(5); Asyncore::loop();
Asyncore is a basic infrastructure for asyncronous socket programming. It provides an implementation of "reactive socket" and it provides hooks for handling events. Code must be written into these hooks (handlers).
Asyncore captures the state of each connection (at the lowest level there is a call to select() and poll()) and it relies on the work to be done on the basis of the connection status (handler).
To manage an asyncronous socket handler instantiate a subclass of Asyncore::Dispatcher and override methods that follow:
writable readble handle_connect handle_accept handle_read handle_write handle_close handle_expt handle_error
Enter a polling loop that terminates after count passes or all open channels have been closed. All arguments are optional. The count parameter defaults to undef, resulting in the loop terminating only when all channels have been closed. The timeout argument sets the timeout parameter for the appropriate select() or poll() call, measured in seconds; the default is 30 seconds. [The use_poll parameter, if true, indicates that poll() should be used in preference to select() (the default is False) TBD].
The map parameter is an hash reference whose items are the channels to watch. As channels are closed they are deleted from their map. If map is omitted, a global map is used. Channels (instances of Asyncore::Dispatcher, Asynchat::async_chat() and subclasses thereof) can freely be mixed in the map.
This module is a porting of asyncore.py written in python.
LGPL
To install Asyncore, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Asyncore
CPAN shell
perl -MCPAN -e shell install Asyncore
For more information on module installation, please visit the detailed CPAN module installation guide.