peb_send_byname — Send an Erlang message by process name
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.
The registered process name on the Erlang node.
An Erlang message term encoded by peb_encode().
The Erlang node connection. If the link identifier is not specified, the last link opened by peb_connect() is assumed.
Returns TRUE on success or FALSE on failure.
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].