You are looking at historical revision 21135 of this page. It may differ significantly from its current revision.
The binding is currently fairly low-level as it mostly directly maps to the C API with only a few abstractions to make it more Scheme-like. More of those will follow in future versions.
Currently, the zmq egg provides bindings for interacting with ZeroMQ contexts, sockets, messages and poll-items.
Returns the ZeroMQ version as a list of the form (major minor patch).
Contexts[parameter] (zmq-default-context [context])
The ZeroMQ context used by all make-socket calls as the default context argument. Usually, you only need one context per application (unless you know what you need more than one for). Note that this parameter is initialized lazily upon the first call to make-socket. See also: zmq-io-threads.[parameter] (zmq-io-threads [number])
number of I/O threads to use for the zmq-default-context. Default: 1.[procedure] (make-context number)
Creates a new ZeroMQ context using number I/O threads.[procedure] (context? context)
Check whether context is a ZeroMQ context.
Sockets[procedure] (make-socket type [context])
Create a ZeroMQ socket of type, which must be one of the symbols pull, push, pair, pub, sub, req, rep, xreq or xrep. See the zmq_socket documentation for information about what the different types mean. context must be a ZeroMQ context and is zmq-default-context by default.[procedure] (socket? socket)
Check whether socket is a ZeroMQ socket.[procedure] (close-socket socket)
Close the ZeroMQ socket. This is usually done by the finalizer so you only have to call this if you want to close a socket early for whatever reason.[procedure] (bind-socket socket endpoint)
Bind socket to endpoint which must be given as a string of the format transport://address (for details, see the documentation for zmq_bind).[procedure] (connect-socket socket endpoint)
Connect socket to endpoint which is given as a string of the format transport://address (for details, see the documentation for zmq_connect).[procedure] (socket-option-set! socket option value)
Destructively set option (a symbol) of socket to value (type depending on the respective option). The following options are available:
- high water mark (integer, maximum number of outstanding messages)
- disk offload size (integer, bytes)
- I/O thread affinity (integer, bitmap)
- socket identity (string, max. 255 bytes)
- add message filter (string, message prefix)
- remove message filter (string, message prefix)
- multicast data rate (integer, kilobits per second)
- multicast recovery interval (integer, seconds)
- multicast loopback (boolean)
- kernel transmit buffer size (integer, bytes, 0 for OS default)
- kernel receive buffer size (integer, bytes, 0 for OS default)
For more detailed descriptions of the options, see the documentation for zmq_setsockopt.[procedure] (socket-option socket option)
Retrieve socket's current option value. option must be given as one the symbols hwm, swap, affinity, rate, recovery-ivl, sndbuf, rcvbuf, rcvmore, mcast-loop or identity. For descriptions of the individual options see the documentation for zmq_getsockopt.
Messages[procedure] (make-message [data-or-size])
If the optional argument data-or-size is not given (or #f), create an empty message. If a string is given, use it as the message's payload. If an integer is given, allocate a message of that many bytes.[procedure] (message? message)
Check whether message is a ZeroMQ message record.[procedure] (message-size message)
Retrieve message's size in bytes.[procedure] (message->string message)
Retrieve message's payload as a string.[procedure] (copy-message message)
Rteurn a copy of message. Note that this actually copies message's data, i.e. it doesn't bind the API call zmq_msg_copy.
Communication[procedure] (send-message socket message #!key non-blocking send-more)
Send message via socket. If non-blocking is not #f, the function call will not block (default: #f). If send-more is not #f, mark this message as part of a multi-part messaging and that further parts are to follow (see the documentation about multi-part messages for more information, default: #f).[procedure] (receive-message socket #!key non-blocking)
Receive the next message from socket. If non-blocking if not #f, the function call will not block and return #f if no message is available (default: #f).
Copyright (C) 2010 Moritz Heidkamp
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA