Qore zmq Module 1.0.2
|
The zmq
module provides an API for socket operations based on the ZeroMQ library.
Classes provided by this module:
Functions provided by this module:
Unlike the ZeroMQ C library which uses an unlimited timeout period on socket send and receive operations by default, the socket timeout in the Qore ZSocket class is set by default to two minutes; to change the default timeout, call one of the following methods after creating the object:
Endpoints have the following format:
[@|>]transport://address
Endpoint prefixes have the following meaning:
@
: bind the socket>
: connect to the remote socketExample transports:
tcp://
: for TCP socket connectionsinproc://
: for in-process connectionstcp://
endpoints support binding on a random free port if you specify the port number as "*"
, "!"
, or 0
and support binding on all interfaces if you specify the interface or host name as "*"
.
Examples
Endpoint | Description |
@tcp://127.0.0.1:0 | bind to random port on localhost |
@tcp://127.0.0.1:* | bind to random port on localhost |
@tcp://127.0.0.1:! | bind to random port on localhost |
@tcp://*:0 | bind to random port on all interfaces |
@tcp://*:* | bind to random port on all interfaces |
@tcp://*:! | bind to random port on all interfaces |
Generally exceptions are thrown if an error occurs in ZeroMQ calls. In such cases, the arg
key of the exception hash will contain the ZeroMQ errno value.
Encryption is supported using the Curve implementation in ZeroMQ.
Encryption keys must be either 32-byte binary values or 40-byte Z85 formatted printable strings. Z85 formatted printable strings can be generated with the zmq_z85_encode().
A public key must be generated from the private key; this can be done with either the zmq_curve_keypair() function, which generates a random private key and a matching public key, or with the zmq_curve_public() function.
Encryption options are set with the ZSocket::setOption() method; see the following example for information on how to set the encryption settings on the client and the server.
qpp
from Qore 1.12.4+zmq_ctx_destroy()
cannot be called after zmq_ctx_term()
as it will cause a core dump (issue 4446)