peb_send_byname

peb_send_bynameSend an Erlang message by process name

Description

bool peb_send_byname ( string $registered_process_name , resource $message_identifier ,[ resource $link_identifier ] )

peb_send_byname() send an Erlang message to the Erlang node that's associated with the specified link identifier. If link_identifier isn't specified, the last opened link is used.

Parameters

registered_process_name

The registered process name on the Erlang node.

message_identifier

An Erlang message term encoded by peb_encode().

link_identifier

The Erlang node connection. If the link identifier is not specified, the last link opened by peb_connect() is assumed.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 peb_send_byname() example

<?php
$link 
peb_connect('node@host.domain',  'secret_cookie');
if (!
$link) {
    die(
'Could not connect: ' peb_error());
}

$msg peb_encode('[~a,~a]', array(
                                   array( 
'hello''friend' )
                                  )
                 );
peb_send_byname('pong',$msg,$link);

peb_close($link);
?> 

pong.erl example code

-module( pong ).
-export( [ start/0, pong/0 ] ).

start() ->
    Mypid = spawn( pong, pong, [ ] ),
    register( pong, Mypid).

pong() ->
    receive
        quit -> ok;
        X ->
            io:fwrite( "Got ~p.~n", [ X ] ),
            pong()
    end.

will output (on Erlang side):

Got [hello,friend].

See Also