Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: egg]] == remote-mailbox [[toc:]] == 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 ==== remote-mailbox-default-tcp-port-no <parameter>(remote-mailbox-default-tcp-port-no [TCP-PORT-NO]) -> fixnum</parameter> The standard port number to establish a remote mailbox connection. Defaults to the environment variable {{REMOTE_MAILBOX_TCP_PORT}}, or {{63001}} if undefined at startup. ==== remote-mailbox-default-expected-size <parameter>(remote-mailbox-default-expected-size [EXPECTED]) -> fixnum</parameter> The expected number of remote mailboxes, either as client or server. ; {{EXPECTED}} : {{fixnum}} ; Defaults to 8. Defaults to the environment variable {{REMOTE_MAILBOX_EXPECTED}}, or {{8}} if undefined at startup. ==== remote-mailbox-default-hostname <parameter>(remote-mailbox-default-hostname [HOSTNAME]) -> string</parameter> The host name to establish a remote mailbox connection. Defaults to the environment variable {{REMOTE_MAILBOX_HOSTNAME}}, or {{"localhost"}} if undefined at startup. === Client ==== Usage <enscript language=scheme> (import remote-mailbox-client) </enscript> ==== remote-mailbox-default-connect <parameter>(remote-mailbox-default-connect [PROCEDURE]) -> procedure</parameter> The procedure used to establish network connections for a remote mailbox. Defaults to {{tcp-connect}} and must be signature-compatible. ==== remote-mailbox-default-hostname <parameter>(remote-mailbox-default-hostname REMOTE-MAILBOX)</parameter> Returns the {{REMOTE-MAILBOX}} hostname. ==== make-remote-mailbox <procedure>(make-remote-mailbox NAME [#:hostname HOSTNAME] [#:tcp-port-no TCP-PORT-NO] [#:connect CONNECT]) -> remote-mailbox</procedure> Returns a unique {{remote-mailbox}} object for the specified {{NAME}}. ; {{NAME}} : {{string}} ; ; {{HOSTNAME}} : {{string}} ;. Defaults to {{(remote-mailbox-default-tcp-port-no)}}. ; {{TCP-PORT-NO}} : {{fixnum in [0 65535] or {{#f}}}} ; Defaults to {{(remote-mailbox-default-hostname)}}. ; {{CONNECT}} : {{procedure}} ; Defaults to {{(remote-mailbox-default-connect)}}. When {{TCP-PORT-NO}} is {{#f}} the {{HOSTNAME}} must contain the port or service. ==== remote-mailbox? <procedure>(remote-mailbox? OBJECT)</procedure> Is the {{OBJECT}} a valid {{remote-mailbox}}? ==== remote-mailbox-name <procedure>(remote-mailbox-name REMOTE-MAILBOX)</procedure> Returns the {{REMOTE-MAILBOX}} name. ==== remote-mailbox-tcp-port-no <procedure>(remote-mailbox-tcp-port-no REMOTE-MAILBOX)</procedure> Returns the {{REMOTE-MAILBOX}} tcp-port-no. ==== remote-mailbox-connected? <procedure>(remote-mailbox-connected? REMOTE-MAILBOX)</procedure> Is the {{REMOTE-MAILBOX}} connected? (Has it been used?) ==== remote-mailboxes <procedure>(remote-mailboxes) -> (list-of remote-mailbox)</procedure> Returns mailboxes. ==== remote-mailbox-send! <procedure>(remote-mailbox-send! REMOTE-MAILBOX OBJECT)</procedure> Transmit the {{OBJECT}} to the {{REMOTE-MAILBOX}}. ==== drop-remote-mailbox! <procedure>(drop-remote-mailbox! REMOTE-MAILBOX)</procedure> Invalidate and forget the {{REMOTE-MAILBOX}}. ==== drop-remote-mailboxes! <procedure>(drop-remote-mailboxes!)</procedure> Invalidate and forget all the remote mailboxes. Performs a reset to the initial state. === Server ==== Usage <enscript language=scheme> (import remote-mailbox-server) </enscript> ==== remote-mailbox-default-listen <parameter>(remote-mailbox-default-listen [PROCEDURE]) -> procedure</parameter> The procedure used to establish network connections for a remote mailbox. Defaults to {{tcp-listen}} and must be signature-compatible. ==== remote-mailbox-default-auto-create? <parameter>(remote-mailbox-default-auto-create? [AUTO-CREATE?]) -> boolean</parameter> Automatically create local-mailbox? Defaults to {{#t}}. ==== make-remote-mailbox-server <procedure>(make-remote-mailbox-server [#:name NAME] [#:tcp-port-no TCP-PORT-NO] [#:listen LISTEN] [#:request-limit REQUEST-LIMIT] [#: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}} : {{symbol}} ; Defaults to {{rtmbsv#}}. ; {{TCP-PORT-NO}} : {{fixnum in [0 65535] or {{#f}}}} ; Defaults to {{(remote-mailbox-default-tcp-port-no)}} ; {{LISTEN}} : {{procedure}} ; Defaults to {{(remote-mailbox-default-listen)}} ; {{REQUEST-LIMIT}} : {{fixnum}} ; The tcp-server upper limit for currently executing requests. Defaults to {{10000}}. ; {{AUTO-CREATE?}} : {{boolean}} ; Automatically create local-mailbox. Defaults to {{#t}} ; {{DEBUG}} :{{(or false string)}} ; Print tcp diagnostics with {{DEBUG}} prefix when true. Defaults to {{#f}} ==== make-remote-mailbox-server-thread <procedure>(make-remote-mailbox-server-thread REMOTE-MAILBOX-SERVER) -> thread</procedure> Returns a thread that, when started, will run the {{REMOTE-MAILBOX-SERVER}}. ==== remote-mailbox-server? <procedure>(remote-mailbox-server? OBJECT) -> boolean</procedure> Is the {{OBJECT}} a {{remote-mailbox-server}}? ==== remote-mailbox-server-name <procedure>(remote-mailbox-server-name REMOTE-MAILBOX-SERVER) -> string</procedure> Returns the name of the specified {{REMOTE-MAILBOX-SERVER}}. ==== remote-mailbox-server-auto-create? <procedure>(remote-mailbox-server-auto-create? REMOTE-MAILBOX-SERVER) -> boolean</procedure> ==== remote-mailbox-server-listener <procedure>(remote-mailbox-server-listener REMOTE-MAILBOX-SERVER) -> procedure</procedure> Returns the listener object for the specified {{REMOTE-MAILBOX-SERVER}}. ==== remote-mailbox-server-request-limit <procedure>(remote-mailbox-server-request-limit REMOTE-MAILBOX-SERVER) -> fixnum</procedure> ==== remote-mailbox-server-debug <procedure>(remote-mailbox-server-debug REMOTE-MAILBOX-SERVER)</procedure> ==== remote-mailbox-server-run! <procedure>(remote-mailbox-server-run! REMOTE-MAILBOX-SERVER)</procedure> Starts the server continuously processing remote mailbox sends until the connection is closed. ==== remote-mailbox-server-start! <procedure>(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-stop! <procedure>(remote-mailbox-server-stop! REMOTE-MAILBOX-SERVER)</procedure> Closes the connection & stops the server thread. ==== server-local-mailbox <procedure>(server-local-mailbox REMOTE-MAILBOX-SERVER NAME) -> mailbox</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! (server-local-mailbox REMOTE-MAILBOX-SERVER NAME))}} ==== drop-server-local-mailbox! <procedure>(drop-server-local-mailbox! REMOTE-MAILBOX-SERVER NAME)</procedure> Forget the server's mailbox. ==== server-local-mailboxes <procedure>(server-local-mailboxes REMOTE-MAILBOX-SERVER) -> (list-of mailbox)</procedure> Returns a list of all the mailboxes created for the server. === Remote Mailbox Service A, singleton, convenience interface for {{remove-mailbox-server}}. ==== Usage <enscript language=scheme> (import remote-mailbox-service) </enscript> ==== remote-mailbox-service <procedure>(remote-mailbox-service NAME [CREATE? [DEBUG]])</procedure> This is a convenience interface and only recommended for the simplest of situations. 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. The {{AUTO-CREATE?}} argument is passed on to {{server-local-mailbox}}. To receive remote messages: {{(mailbox-receive! (remote-mailbox-service NAME))}} ==== remote-mailbox-service-info <procedure>(remote-mailbox-service-info) -> remote-mailbox-server thread</procedure> The {{remote-mailbox-server}} & {{thread}} for {{remote-mailbox-service}}. ==== remote-mailbox-service-stop! <procedure>(remote-mailbox-service-stop!) -> void</procedure> The {{thread}} object for {{local-mailbox}}. === Adapter ==== Usage <enscript language=scheme> (import remote-mailbox-adapter) </enscript> ==== serializer <parameter>(serializer [PROCEDURE]) -> procedure</parameter> Parameter for Scheme object serialization procedure. Default is {{s11n::serialize}}. ==== deserializer <parameter>(deserializer [PROCEDURE]) -> procedure</parameter> Parameter for Scheme object deserialization procedure. Default is {{s11n::deserialize}}. ==== deserializer-input <parameter>(deserializer-input [INPUT-PORT]) -> input-port</parameter> Parameter for deserialization procedure input. Default is {{(current-input-port)}}. ==== serializer-output <parameter>(serializer-output [OUTPUT-PORT]) -> output-port</parameter> Parameter for serialization procedure output. Default is {{(current-output-port)}}. ==== serialize <procedure>(serialize OBJECT [OUTPUT-PORT (serializer-output)])</procedure> Serialize the {{OBJECT}} to the {{OUTPUT-PORT}}. ==== deserialize <procedure>(deserialize [INPUT-PORT (deserializer-input)]) -> *</procedure> Deserialize the {{OBJECT}} from the {{INPUT-PORT}}. == Requirements [[tcp-server]] [[s11n]] [[mailbox]] [[srfi-18]] [[synch]] [[miscmacros]] [[moremacros]] [[condition-utils]] [[check-errors]] [[llrb-tree]] [[test]] == 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. == Author [[/users/kon-lovett|Kon Lovett]] == Version history ; 1.0.6 : Better types & test. ; 1.0.5 : Better types & test. ; 1.0.4 : Use {{llrb-tree}} instead of {{srfi-69}}. ; 1.0.3 : Add {{remote-mailbox-service}}. ; 1.0.2 : Add {{remote-mailbox-default-expected-size}}. ; 1.0.1 : Clarify types. ; 1.0.0 : Initial Chicken 5 release. == License Copyright (C) 2009-2022 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.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you subtract 24 from 3?