Contents

rpc-client

(rpc-connect host port user pass notification-handler . pass-hasher) : rpc-handle

Connects to host <host> on port <port> with account <user> and password <pass>

The notification-handler must be #f if no notifications from the server are handled, otherwise the notification handler must be a function of one argument. The server can send notifications to clients. They depend on the server. The client can handle these notifications using the given notification handler.

The pass-hasher is a function that is called with a password and a chalenge. The function must be used to hash the password and the chalenge together.

This function tries to login right away. If the login fails, rpc-valid? will return #f.

The result of rpc-connect is a handle. rpc-valid? returns #t, if the handle is valid, #f otherwise.

(rpc-notifications-handler handle F)

Sets the notification handler for the given client handle to a new function.

Returns handle.

(rpc-disconnect handle)

Disconnects from the mzrpc server.

Returns 'io-error if a not valid handle is given, but closes the TCP connection, and kills a started thread

Returns 'disconnected

(rpc-shutdown handle)

If the user is autorised to do so (i.e. has 'admin level), enables the user to shutdown the server if no other clients are connected.

Returns 'forbidden, if the user is not of autorisation type 'admin

Returns 'clients-connected, if more than 1 client is connected.

Returns 'io-error if a not valid handle is given, but closes the TCP connection

Returns 'ok and shuts down the server, otherwise

(rpc-shutdown handle)

If the user is autorised to do so (i.e. has 'admin level), enables the user to shutdown the server if no other clients are connected.

Returns 'forbidden, if the user is not of autorisation type 'admin

Returns 'clients-connected, if more than 1 client is connected.

Returns 'io-error if a not valid handle is given, but closes the TCP connection

Returns 'ok and shuts down the server, otherwise

(rpc-valid? handle)

Returns #t, if the handle is valid.

Returns #f, otherwise.

(rpc-diagnose handle)

Returns 'no-connect, if the server could not be connected (on the tcp/ip level)

Returns 'wrong-password, if one cannot login with the given user (on mzrpc level)

Returns 'io-error, if an io-error occured during operation (on the tcp/ip level)

Returns 'call-error, if an error occured during a call to the server (on the rpc level)

Returns 'ok, if nothing is wrong

(rpc-message handle)

Returns the last error message associated with the handle.

(rpc-symbol-call handle f:symbol ...)

RPCs function f with arguments ...

Returns whatever f would return if no error occured.

Returns '%rpc-error, if an error is returned (wrong function call).

Returns '%rpc-fatal, if a problem some other problem has occured, handle will have been invalidated.

Raises an error if called with an invalid handle.

(rpc-call handle f ...)

Scheme syntax that calls rpc-symbol-call with 'f.

(rpc-connected handle)

Returns the number of clients connected to the server.

(rpc-global-connect host port user pass notification-handler . pass-hasher) : handle

Calls rpc-connect and sets the global handler for this program to the returned handle.

Returns the global handle.

(rpc-global-handle)

Returns the current global RPC handle (or #f if no global handle is set).

(rpc-global-disconnect)

Calls rpc-disconnect with the global handle from the mzrpc server.

(rpc-global-handle! handle)

(Re)set the global handle to <handle>

Returns handle.

(rpc-client-define)

The same as define, but defines an rpc function that uses the global client handler for calling the equivalent with rpc-define defined function at the server side.

(rpc-local-define)

The same as define, but defines an rpc function that uses a local client handler for calling the equivalent with rpc-define defined function at the server side.

Example:

 (rpc-local-define (rpc-plus a b))
  (let ((handle (rpc-connect "server.server.org" 4304 "user" "pass" #f)))
     (display (format "~a~%" (rpc-plus handle 3 4))
     (rpc-disconnect handle))