Distributed::Process::Client - a class to run a client in a Distributed::Process cluster.


    use Distributed::Process;
    use Distributed::Process::Client;
    use MyTest;

    $c = new Distributed::Process::Client
        -id           => 'client1',
        -worker_class => 'MyTest',
        -port         => 8147,
        -host         => 'localhost',


This class handles the client part of the cluster. It derives its handling of the network connection from Distributed::Process::Interface.

A D::P::Worker object must be associated to the Client, by means of the worker() or worker_class() methods, so that the client can run methods from it when requested to do so by the server.


A D::P::Client object will react on the following commands received on its in_handle().


Calls the worker's run() method. This is method should be overloaded by subclasses of D::P::Worker to perform the real job that is to be distributed on the cluster.


Calls the worker's reset_result() method to flush its list of results.


Exits the program.


Returns the results from the worker. The results are preceeded with the line /begin_results and followed by the word ok. Each result line gets prefixed with the client's id() and a tab character ("\t", ASCII 0x09).

The worker itself returns its result line prefixed with a timestamp. An example of output could thus be:

    client1     20050316-152519 Running method test1
    client1     20050316-152522 Time for running test1: 2.1234 seconds



Reads line coming in from handle() and processes them.

Each line is first chomped and split on whitespace, and an action is performed depending on the first word on the line. See the list of known commands above.


These three are synonyms for the handle() method that returns the IO::Socket::INET object implementing the connection to the server.

The first call to handle() creates this object, effectively establishing the connection to port port() on host host().

worker OBJECT

Sets or returns the current worker object. OBJECT should be an instance of Distributed::Process::Worker or, most probably, of a subclass of it. If OBJECT is not provided, the fist call to worker() will instanciate an object of the class returned by worker_class(), passing to its constructor the arguments returned by worker_args().

worker_args LIST
worker_args ARRAYREF

The list of arguments to pass to the worker_class() constructor. If the first argument is an array ref, it will be dereferenced.

Returns the former list of arguments or the current list when invoked without arguments.


The following list describes the attributes of this class. They must only be accessed through their accessors. When called with an argument, the accessor methods set their attribute's value to that argument and return its former value. When called without arguments, they return the current value.


A unique identifier for the client. This will be prepended to the lines sent back to the server as a response to the /get_result command. The process id ($$) is returned if id() is not set.


The name of the class to use when instanciating a D::P::Worker object.


The host and port where to connect to the server.


Distributed::Process::Interface, Distributed::Process::Worker,


Cédric Bouvier, <>


Please report any bugs or feature requests to, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


Copyright 2005 Cédric Bouvier, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 268:

Non-ASCII character seen before =encoding in 'Cédric'. Assuming ISO8859-1