chickadee » rpc » rpc:procedure

(rpc:procedure name host #!optional (port (rpc:default-server-port))) => <procedure>procedure

Creates a procedure that can be called with any number of parameters to invoke the externally callable procedure published as name on the server at host:port with the given arguments.

The arguments are scanned for procedures and if any such are found, those in the reverse lookup table are replaced with callback stubs before all the parameters are serialized over the network connection. Callback stubs are small procedures that use the value of the rpc:current-peer and rpc:default-server-port parameters in the remote server thread in order to determine where they came from and to use rpc:procedure again to connect back to their home and execute their real counterpart.

Some care has been taken to isolate code executing in an RPC server thread properly:

  • Exceptions caused in the remotely executing code are caught, sent back to the client and rethrown there.
  • The current-input-port, current-output-port and current-error-port parameters are changed for the remotely executing code. current-input-port never yields any input and the two output ports accumulate data into strings that are sent back to the client and printed on the current-output-port and current-error-port there.