<<<<<<< (null)="======"> dp_RPC

dp_RPC

Syntax

dp_RPC rpcChan ?-timeout amount ?-timeoutReturn script?? ?-events evtList? rpcCmd ?args ...?

Comments

dp_RPC allows one to send a Tcl expression to a remote Tcl interpreter to be evaluated by it. rpcChan is a channel opened with dp_connect and registered for RPCs with dp_admin. Unlike dp_RDO, this command waits for a return code, although because of the asynchronous nature of events and I/O, RPC return codes are not guaranteed in any specific order. If one does not need a return code, it is highly recommended that dp_RDO be used instead; it is much faster and far less complex.

The timeout amount specifies how long dp_RPC will block before returning an error and is in milliseconds. script is the script to evaluate if the RPC times out. Specifying a timeout script without a timeout value is invalid. The prototype for the timeoutReturn script is as follows:

proc errorHandler {channelName} {}

evtList is a normal Tcl event list that tells DP which events to respond to while waiting for the RPC to return. See the Tcl documentation on events for valid parameters.

dp_RPC returns the return value of the rpcCmd.


If you are using RPCs with just tclsh, an RPC will not execute asynchronously due to the fact that Tcl relies on Tcl_DoOneEvent() to process events. It is recommended that you use wish or add a vwait command in your script to force Tcl into an event loop. As an example, if you send an RPC to puts "foobar", the receiving intrepreter will not print "foobar" until update is called.


Examples

dp_RPC $myChan puts stdout hello
dp_RPC $myChan -timeout 100 puts stdout foo
dp_RPC $myChan -timeout 100 -timeoutReturn "set a 1" -events all puts stdout hello