rcp:cast/4 example?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

rcp:cast/4 example?

Bengt Kleberg-2

> From: "andy allen" <recycledelectrons>
> I'm looking for advice on a simple example of rpc:cast/4.

> To make certain that the function I am casting to works, I can call it with
> the following line from an Erlang shell:
> mlgCpt:trace_call({{switch_dev_id, 1}, {channel, all}}).
> It executes past a "SYS_DBG" statement, then crashes. But when I cast to it,
> it should at least execute the "SYS_DBG" statement, right?
> -=-=-
> For the uninitiated:
> 1. rpc is a library in the standard Erlang distribution,
> 2. ?SYS_DBG is a macro that works like a printf.


Since you do not explicitly state the result of the cast I am assuming
that nothing happens. Please correct me if I am wrong.

The most interesting part is this:
 > 2. ?SYS_DBG is a macro that works like a printf.
(may I assume that you mean io:format(), and not printf() :-)

Anyway, it seems to be impossible to do io:format() from
rpc:cast/call(). The things one wants displayed end up on the calling
node, not the node one did the rcp call to. Strange, but true. So, have
you tried rpc:call(Node, mlgCpt, trace_call, [Data])? This to make
certain that ?SYS_DBG actually displys on the right node. When rpc:call
works it would be time to switch to rpc:cast.

Bengt Kleberg