Labrador::Dispatcher::Connections::run(2680, $event_handler); warn "Server has been shutdown\n"; exit;
This class performs the non-blocking network IO with each subcrawler. It passes on command events to the event handler object, whose job it is to pass the command on to the appropriate command handler. Other events are handled by the events handler, such as unexpected disconection of a client.
This class is a singleton - ie it cannot be instantiated as an object. The non-blocking network code is heavily based on Recipe 17.17 in the Perl Cookbook, with some alterations where I disagree with its handling of partial sends and EWOULDBLOCK. Further reference should be made to Richard W. Stevens book on Unix Network Progamming.
This class calls several methods of $event_handler to represent events occurring. The event handling methods are expected to exist in the provided $event_handler.. They are listed below:
NB: Event handling code is not permitted to write to $client at any time.
Starts up all the network gubbins. Does not return unless a shutdown is signalled by calling shutdown().
Close all sockets, causes a return from run()
$client will be disconnected a the end of the current iteration of the mail while(1) loop. By delaying the disconnection until the end of the iteration, this means the final message reply to the client can be written.
Returns the IP address of $client
Run this $coderef every $every seconds, called $name.
Returns an array of network level stats
Enables connection logging to $filename.
Disabled connection logging.
NB: Should not be called by client code, but documented here for completeness.
Handle the disconnection of $client. Called by disconnect_client() (indirectly), and also when an error occurs when reading or writing to a socket, and the connection should be dropped. Handles removal of all lowlevel mapping - ie per-client buffers.
Deals with all pending requests from $client, by taking exactly one command from the start of the client's ready buffer, processing the request (by calling forward to the Event handler), and the supplying the returned data to the client by appending it to the client's outbuffer.
Puts the given $socket into non-blocking mode.
$Revision: 1.18 $