remote-mailbox
TOC »
- remote-mailbox
- Documentation
- Common Parameters
- Client
- Server
- Usage
- default-remote-mailbox-deserializer
- default-remote-mailbox-listen
- default-remote-mailbox-auto-create?
- make-remote-mailbox-server
- make-remote-mailbox-server-thread
- remote-mailbox-server?
- remote-mailbox-server-name
- remote-mailbox-server-auto-create?
- remote-mailbox-server-deserializer
- remote-mailbox-server-listener
- remote-mailbox-server-request-limit
- remote-mailbox-server-debug
- remote-mailbox-server-start!
- remote-mailbox-server-run!
- local-mailbox/server
- drop-local-mailbox!/server
- local-mailbox-names/server
- local-mailbox
- local-mailbox-start!
- local-mailbox-server
- local-mailbox-thread
- Requirements
- Bugs and Limitations
- Author
- Version history
- License
Documentation
Purports to provide an API for sending and receiving remote messages. This egg attempts to duplicate the mailbox egg semantics across an IP connection.
Common Parameters
default-remote-mailbox-tcp-port
- (default-remote-mailbox-tcp-port [TCP-PORT]) procedure
The standard port number to establish a remote mailbox connection. Defaults to 63001.
default-remote-mailbox-hostname
- (default-remote-mailbox-hostname [HOST-NHAME]) procedure
The host name to establish a remote mailbox connection. Defaults to "localhost".
Client
Usage
(require-extension remote-mailbox-client)
default-remote-mailbox-serializer
- (default-remote-mailbox-serializer [PROCEDURE]) procedure
The optional serialize failure handler procedure. Must be #f or a procedure/1.
default-remote-mailbox-connect
- (default-remote-mailbox-connect [PROCEDURE]) procedure
The procedure used to establish network connections for a remote mailbox. Defaults to tcp-connect and must be signature-compatible.
remote-mailbox
- (remote-mailbox NAME [#:hostname HOSTNAME] [#:tcp-port TCP-PORT] [#:connect CONNECT]) procedure
Returns a unique remote-mailbox object for the specified NAME.
- HOSTNAME
- A string. Defaults to (default-remote-mailbox-tcp-port).
- TCP-PORT
- A fixnum in [0 65535] or #f. Defaults to (default-remote-mailbox-hostname).
- CONNECT
- A procedure. Defaults to (default-remote-mailbox-connect).
When TCP-PORT is #f the HOSTNAME must contain the port or service.
remote-mailbox?
- (remote-mailbox? OBJECT) procedure
Is the OBJECT a valid remote-mailbox?
remote-mailbox-name
- (remote-mailbox-name REMOTE-MAILBOX) procedure
Returns the REMOTE-MAILBOX name.
default-remote-mailbox-hostname
- (default-remote-mailbox-hostname REMOTE-MAILBOX) procedure
Returns the REMOTE-MAILBOX hostname.
remote-mailbox-tcp-port
- (remote-mailbox-tcp-port REMOTE-MAILBOX) procedure
Returns the REMOTE-MAILBOX tcp-port.
remote-mailbox-connected?
- (remote-mailbox-connected? REMOTE-MAILBOX) procedure
Is the REMOTE-MAILBOX connected? (Has it been used?)
remote-mailbox-send!
- (remote-mailbox-send! REMOTE-MAILBOX OBJECT [SERIALIZER]) procedure
Transmit the OBJECT to the REMOTE-MAILBOX, using the SERIALIZER, which defaults to (default-remote-mailbox-serializer).
drop-remote-mailbox!
- (drop-remote-mailbox! REMOTE-MAILBOX) procedure
Invalidate and forget the REMOTE-MAILBOX.
drop-all-remote-mailboxes
- (drop-remote-mailboxes!) procedure
Invalidate and forget all the remote mailboxes. Performs a reset to the initial state.
Server
Usage
(require-extension remote-mailbox-server)
default-remote-mailbox-deserializer
- (default-remote-mailbox-deserializer [PROCEDURE]) procedure
The optional deserialize failure handler procedure. Must be #f or a procedure/2.
default-remote-mailbox-listen
- (default-remote-mailbox-listen [PROCEDURE]) procedure
The procedure used to establish network connections for a remote mailbox. Defaults to tcp-listen and must be signature-compatible.
default-remote-mailbox-auto-create?
- (default-remote-mailbox-auto-create? [AUTO-CREATE?]) procedure
Automatically create local-mailbox? Defaults to #t.
make-remote-mailbox-server
- (make-remote-mailbox-server [#:name NAME] [#:tcp-port TCP-PORT] [#:listen LISTEN] [#:request-limit REQUEST-LIMIT] [#:deserializer DESERIALIZER] [#:auto-create? AUTO-CREATE?] [#:debug DEBUG]) procedure
Creates and returns a remote-mailbox-server. Uses make-tcp-server to create a server procedure. The server threads spawned by this procedure are continuously processing remote mailbox sends until the connection is closed.)
- NAME
- Defaults to remote-mailbox-server:#
- TCP-PORT
- Defaults to (default-remote-mailbox-tcp-port)
- LISTEN
- Defaults to (default-remote-mailbox-listen)
- DESERIALIZER
- Defaults to (default-remote-mailbox-deserializer)
- REQUEST-LIMIT
- The tcp-server upper limit for currently executing requests. Defaults to 10000.
- AUTO-CREATE?
- Automatically create local-mailbox. Defaults to #t
- DEBUG
- Print tcp diagnostics with DEBUG prefix when true. Defaults to #f
make-remote-mailbox-server-thread
- (make-remote-mailbox-server-thread REMOTE-MAILBOX-SERVER) procedure
Returns a thread that, when started, will run the REMOTE-MAILBOX-SERVER.
remote-mailbox-server?
- (remote-mailbox-server? OBJECT) procedure
Is the OBJECT a remote-mailbox-server?
remote-mailbox-server-name
- (remote-mailbox-server-name REMOTE-MAILBOX-SERVER) procedure
Returns the name of the specified REMOTE-MAILBOX-SERVER.
remote-mailbox-server-auto-create?
remote-mailbox-server-deserializer
remote-mailbox-server-listener
- (remote-mailbox-server-listener REMOTE-MAILBOX-SERVER) procedure
Returns the listener object for the specified REMOTE-MAILBOX-SERVER.
remote-mailbox-server-request-limit
remote-mailbox-server-debug
remote-mailbox-server-start!
- (remote-mailbox-server-start! REMOTE-MAILBOX-SERVER) procedure
Starts the server in a thread continuously processing remote mailbox sends until the connection is closed.
Returns the started thread.
remote-mailbox-server-run!
- (remote-mailbox-server-run! REMOTE-MAILBOX-SERVER) procedure
Starts the server continuously processing remote mailbox sends until the connection is closed.
local-mailbox/server
- (local-mailbox/server REMOTE-MAILBOX-SERVER NAME) procedure
Returns the mailbox of NAME for REMOTE-MAILBOX-SERVER (a mailbox object as returned by the procedure make-mailbox). Should the mailbox not exist it will be created if the REMOTE-MAILBOX-SERVER has a true AUTO-CREATE? flag, otherwise returns #f.
To receive remote messages:
(mailbox-receive! (local-mailbox/server REMOTE-MAILBOX-SERVER NAME))
drop-local-mailbox!/server
- (drop-local-mailbox!/server REMOTE-MAILBOX-SERVER NAME) procedure
Forget the server's mailbox.
local-mailbox-names/server
- (local-mailbox-names/server REMOTE-MAILBOX-SERVER) procedure
Returns a list of all the mailboxes created for the server.
local-mailbox
- (local-mailbox NAME [DEBUG]) procedure
This is a convenience interface and only recommended for the simplest of situations.
When NAME is:
- default-remote-mailbox-server-thread
- returns the thread for the default server.
- default-remote-mailbox-server
- returns the default server record.
- <other symbol>
- returns the mailbox for NAME.
The DEBUG argument is passed on to tcp-server which will print tcp diagnostics with DEBUG as a prefix. The other parameters to make-remote-mailbox-server are defaulted.
The default server is created and run in a separate thread upon the first call.
To receive remote messages:
(mailbox-receive! (local-mailbox NAME))
local-mailbox-start!
- (local-mailbox-start! [DEBUG]) procedure
What local-mailbox does upon the first invocation.
local-mailbox-server
- (local-mailbox-server) => REMOTE-MAILBOX-SERVER procedure
The remote-mailbox-server object for local-mailbox.
local-mailbox-thread
- (local-mailbox-thread) => THREAD procedure
The thread object for local-mailbox.
Requirements
tcp-server s11n mailbox miscmacros synch lookup-table type-errors
Bugs and Limitations
- The sender (client) identity is not part of this API.
- "Curry" to supply BACKLOG and/or HOST arguments to the listen procedure.
- There is not a good way to terminate a tcp-server. The test terminates the thread and then joins under an exception handler. Ugh.
Author
Version history
- 2.0.1
- Explicit requirements.
- 2.0.0
- Initial Chicken 4 release.
License
Copyright (C) 2009 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.