JSONRPC::Transport::TCP - Client component for TCP JSONRPC


JSONRPC-Transport-TCP documentation  | view source Contained in the JSONRPC-Transport-TCP distribution.

Index


NAME

Top

JSONRPC::Transport::TCP - Client component for TCP JSONRPC

SYNOPSIS

Top

    use JSONRPC::Transport::TCP;

    my $rpc = JSONRPC::Transport::TCP->new( host => '127.0.0.1', port => 3000 );
    my $res = $rpc->call('echo', 'arg1', 'arg2' )
        or die $rpc->error;

    print $res->result;

DESCRIPTION

Top

This module is a simple client side implementation about JSONRPC via TCP.

This module doesn't support continual tcp streams, and so it open/close connection on each request.

METHODS

Top

new

Create new client object.

Parameters:

host => 'Str'

Hostname or ip address to connect.

This should be set 'unix/' when you want to connect to unix socket.

port => 'Int | Str'

Port number or unix socket path to connect

connect

Connect remote host.

This module automatically connect on following "call" method, so you have not to call this method.

disconnect

Disconnect the connection

call($method_name, @params)

Call remote method.

When remote method is success, it returns self object that contains result as ->result accessor.

If some error are occurred, it returns undef, and you can check the error by ->error accessor.

Parameters:

$method_name

Remote method name to call

@params

Remote method parameters.

DESTROY

Automatically disconnect when object destroy.

ACCESSORS

Top

result

Contains result of remote method

error

Contains error of remote method

AUTHOR

Top

Daisuke Murase <typester@cpan.org>

COPYRIGHT

Top


JSONRPC-Transport-TCP documentation  | view source Contained in the JSONRPC-Transport-TCP distribution.