Description

Remote Mailbox

Author

Kon Lovett

Requires

Usage

(require-extension remote-mailbox)

Download

remote-mailbox.egg

Documentation

Purports to provide an API for sending and receiving remote messages. This egg attempts to duplicate the mailbox egg send semantics across an IP connection.

Common Parameters

parameter: default-remote-mailbox-port

The standard port number to establish a remote mailbox connection. Defaults to 3001.

Client Parameters

parameter: remote-mailbox-serializer

The optional serialize failure handler procedure. Must be #f or an arity-1 procedure.

parameter: remote-mailbox-connect-procedure

The procedure used to establish network connections for a remote mailbox. Defaults to tcp-connect and must be signature-compatible.

Client Procedures

procedure: (get-remote-mailbox NAME [HOST "localhost"] [PORT (default-remote-mailbox-port)])

Returns the remote mailbox object for the specified NAME, HOST, PORT, and (remote-mailbox-connect-procedure).

procedure: (remote-mailbox? OBJECT)

Is the OBJECT a valid remote mailbox?

procedure: (remote-mailbox-name RCH)

Returns the remote mailbox name.

procedure: (remote-mailbox-host RCH)

Returns the remote mailbox host.

procedure: (remote-mailbox-port RCH)

Returns the remote mailbox port.

procedure: (remote-mailbox-connected? RCH)

Is the remote mailbox connected? (Has this remote mailbox been used?)

procedure: (drop-remote-mailbox! RCH)

Invalidate and forget the remote mailbox.

procedure: (remote-mailbox-send! RCH OBJECT)

Transmit the OBJECT to the remote mailbox, using the (remote-mailbox-serializer).

procedure: (drop-all-remote-mailboxs!)

Invalidate and forget all the remote mailboxs. Performs a reset to the initial state.

Server Parameters

parameter: remote-mailbox-deserializer

The optional deserialize failure handler procedure. Must be #f or an arity-2 procedure.

parameter: remote-mailbox-listen-procedure

The procedure used to establish network connections for a remote mailbox. Defaults to tcp-listen and must be signature-compatible.

Server Procedures

procedure: (get-local-mailbox NAME [CREATE? #t])

Returns the local mailbox (a mailbox object as returned by the procedure 'make-mailbox') for NAME. Should the mailbox not exist it will be created when the CREATE? flag is #t. Otherwise returns #f for a non-existent mailbox.

procedure: (drop-local-mailbox! NAME)

Forget the local mailbox.

procedure: (make-remote-mailbox-server [PORT (default-remote-mailbox-port)])

Uses make-tcp-server to create a server procedure on ((remote-mailbox-listen-procedure) PORT). The server threads spawned by this procedure are continuously processing remote mailbox sends until the connection is closed.

A remote send will automatically create the requested local mailbox.

Use (mailbox-receive! (get-local-mailbox NAME) ...) to get remote messages.

procedure: (run-remote-mailbox-server [PORT (default-remote-mailbox-port)])

Returns the remote mailbox server thread. Should the server thread not exist it will be created with the specified ((remote-mailbox-listen-procedure) PORT) and started.

procedure: (remote-mailbox-server-listener SERVER-THREAD)

Returns the listener object for the specified SERVER-THREAD, as created by run-remote-mailbox-server.

Issues

The sender (client) identity is not part of this API.

The use of port 3001 (in the reserved range) is problematic.

Version

License

Copyright (c) 2006, Kon Lovett.  All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the Software),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.