The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

SYNOPSIS

    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

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

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

result

Contains result of remote method

error

Contains error of remote method

AUTHOR

Daisuke Murase <typester@cpan.org>

COPYRIGHT

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

The full text of the license can be found in the LICENSE file included with this module.