Qore zmq Module
1.0.0
|
The ZSocket class provides the abstract base class for ZeroMQ socket classes. More...
Public Member Methods | |
nothing | attach (*string endpoints, bool do_bind=False) |
Attaches the socket to zero or more endpoints. More... | |
int | bind (string format,...) |
Bind the ZSocket to a formatted endpoint. More... | |
nothing | connect (string format,...) |
Connects the socket to a formatted endpoint. More... | |
copy () | |
Throws an exception; copying ZSocket objects is not currently supported. More... | |
nothing | disconnect (string format,...) |
Disconnects the socket from a formatted endpoint. More... | |
*string | endpoint () |
Returns the last bound endpoint, if any or nothing if not. More... | |
*string | getIdentity () |
retrieves the socket identity string More... | |
auto | getOption (int opt, int bufsize=100) |
Retrieves the value of the given socket option. More... | |
nothing | monitor (int events, string format,...) |
Creates a bound PAIR socket on the given endpoint which will send the specified events to a single client. More... | |
ZFrame | recvFrame () |
Receives a frame from the socket. More... | |
ZMsg | recvMsg () |
Receives a message from the socket. More... | |
nothing | send (Qore::ZMQ::ZMsg msg) |
Sends the given message over the socket; the message is consumed by this call. More... | |
nothing | send (Qore::ZMQ::ZFrame frame, int flags=0) |
Sends the given frame over the socket; the frame is consumed by this call unless Qore::ZMQ::ZFRAME_REUSE is used in the flags argument. More... | |
nothing | send (data val,...) |
Sends one or more strings or binary data objects over the socket. More... | |
nothing | send () |
Sends a zero-length message over the socket. More... | |
nothing | setIdentity (string id) |
Sets the socket identity string. More... | |
setOption (int opt, int value) | |
Sets the given socket option to the given value. More... | |
setOption (int opt, bool value) | |
Sets the given socket option to the given value. More... | |
setOption (int opt, data value) | |
Sets the given socket option to the given value. More... | |
nothing | setRecvHighWaterMark (int value) |
Sets the receive high water mark. More... | |
nothing | setRecvTimeout (timeout timeout_ms) |
Sets the receive timeout in milliseconds. More... | |
nothing | setSendTimeout (timeout timeout_ms) |
Sets the send timeout in milliseconds. More... | |
nothing | setTimeout (timeout timeout_ms) |
Sets the send and receive timeout in milliseconds. More... | |
string | type () |
Returns the socket type as a string. More... | |
nothing | unbind (string format,...) |
Unbinds the socket from a formatted endpoint. More... | |
nothing | waitRead (timeout timeout_ms) |
Waits for data to read on the socket; if data does not arrive before the timeout expires, a ZSOCKET-TIMEOUT-ERROR exception is thrown. More... | |
nothing | waitWrite (timeout timeout_ms) |
Waits for data to be written on the socket; if data is not sent before the timeout expires, a ZSOCKET-TIMEOUT-ERROR exception is thrown. More... | |
Static Public Member Methods | |
static list< hash< ZmqPollInfo > > | poll (list< hash< ZmqPollInfo >> items, timeout timeout_ms) |
polls multiple sockets and returns all sockets with events More... | |
static nothing | proxy (ZSocket frontend, ZSocket backend, *ZSocket capture) |
starts the built-in ZeroMQ proxy to connect messages between two sockets More... | |
The ZSocket class provides the abstract base class for ZeroMQ socket classes.
To poll for events with multiple sockets, use ZSocket::poll()
The socket timeout is set by default to two minutes; to change the default timeout, call one of:
For example, to set the timeout to unlimited:
ZSOCKET-THREAD-ERROR
to be thrown. nothing Qore::ZMQ::ZSocket::attach | ( | *string | endpoints, |
bool | do_bind = False |
||
) |
Attaches the socket to zero or more endpoints.
endpoints | zero or more endpoints, separated by commas and prefixed by '@' (to bind the socket) or '>' (to connect the socket) |
do_bind | determines if endpoints not prefixed with '@' or '>' are bound (do_bind = True) or connected (do_bind = False, the default) |
Throws an exception if there was a syntax error in the endpoints argument
ZSOCKET-CONNECT-ERROR | thrown if there is a connect error |
ZSOCKET-BIND-ERROR | thrown if there is a bind error |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
int Qore::ZMQ::ZSocket::bind | ( | string | format, |
... | |||
) |
Bind the ZSocket to a formatted endpoint.
For tcp://
endpoints, this class supports binding on a random free port if you specify the port number as "*" or \ "0".
format | the format string for the endpoint |
... | optional arguments for the format string |
"tcp://"
endpoints, 0 for other transports. On failure, a ZSOCKET-BIND-ERROR
exception is thrown. Note that when using wildcard or random ports, a port may be reused by different services without clients being aware of this fact. Protocols that use wildcard or random ports should take this into account.ZSOCKET-BIND-ERROR | if an error occurs, this exception is thrown |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
"@"
with this method nothing Qore::ZMQ::ZSocket::connect | ( | string | format, |
... | |||
) |
Connects the socket to a formatted endpoint.
format | the format string for the endpoint |
... | optional arguments for the format string |
Throws an exception if an error occurs connecting to the endpoint
ZSOCKET-CONNECT-ERROR | thrown if an error occurs connecting to the endpoint |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
">"
with this method Qore::ZMQ::ZSocket::copy | ( | ) |
nothing Qore::ZMQ::ZSocket::disconnect | ( | string | format, |
... | |||
) |
Disconnects the socket from a formatted endpoint.
format | the format string for the endpoint |
... | optional arguments for the format string |
Throws an exception if the endpoint was invalid or the function isn't supported on the current socket
ZSOCKET-DISCONNECT-ERROR | thrown if the endpoint was invalid or the function isn't supported on the current socket |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
*string Qore::ZMQ::ZSocket::endpoint | ( | ) |
Returns the last bound endpoint, if any or nothing if not.
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
*string Qore::ZMQ::ZSocket::getIdentity | ( | ) |
retrieves the socket identity string
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
auto Qore::ZMQ::ZSocket::getOption | ( | int | opt, |
int | bufsize = 100 |
||
) |
Retrieves the value of the given socket option.
opt | the option code; see ZSocket Options for possibile values |
bufsize | the size of the buffer for string and binary options |
If any errors occur retrieving the option, an exception is raised.
ZSOCKET-OPTION-ERROR | unknown option |
ZSOCKET-GETOPTION-ERROR | error setting option |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
nothing Qore::ZMQ::ZSocket::monitor | ( | int | events, |
string | format, | ||
... | |||
) |
Creates a bound PAIR
socket on the given endpoint which will send the specified events to a single client.
events | an event code mask combined with binary or; see ZSocket Events for possible values |
format | the format string for the endpoint, which must be an "inproc://" endpoint |
... | optional arguments for the format string |
ZSOCKET-MONITOR-ERROR | this exception is thrown if the internal call to zmq_socket_monitor() fails |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
"inproc://"
endpoints
|
static |
polls multiple sockets and returns all sockets with events
item | list of ZmqPollInfo hashes |
timeout_ms | the poll timeout period |
ZSOCKET-POLL-ERROR | socket element in the items argument is not assigned or there was an error in the poll operation |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
|
static |
starts the built-in ZeroMQ proxy to connect messages between two sockets
frontend | the frontend socket for the proxy |
backend | the backend socket for the proxy |
capture | an optional capture socket to capture frontend and backend messages |
tcp://
and forward on pgm://
.ZSOCKET-PROXY-ERROR | error executing the proxy call |
ZFrame Qore::ZMQ::ZSocket::recvFrame | ( | ) |
Receives a frame from the socket.
ZSOCKET-RECVFRAME-ERROR | thrown if an error occurs during the call |
ZSOCKET-TIMEOUT-ERROR | thrown if a timeout error occurs |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
ZMsg Qore::ZMQ::ZSocket::recvMsg | ( | ) |
Receives a message from the socket.
ZSOCKET-RECVMSG-ERROR | thrown if an error occurs during the call |
ZSOCKET-TIMEOUT-ERROR | thrown if a timeout error occurs |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a non-thread-safe socket and a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
nothing Qore::ZMQ::ZSocket::send | ( | ) |
Sends a zero-length message over the socket.
ZSOCKET-SEND-ERROR | an error occurred sending the data |
ZSOCKET-TIMEOUT-ERROR | thrown if a timeout error occurs |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
nothing Qore::ZMQ::ZSocket::send | ( | data | val, |
... | |||
) |
Sends one or more strings or binary data objects over the socket.
val | the string or binary value to send as a frame over the socket; no encoding convertions are performed on strings |
... | additional arguments must be strings or binary objects or a ZSOCKET-SEND-DATA-ERROR will be thrown; trailing arguments will no value will be ignored, otherwise all additional arguments must be a string or a binary value or a ZSOCKET-SEND-DATA-ERROR exception will be raised |
The ZMQ_SNDMORE flag is set on all frames except the last
ZSOCKET-SEND-ERROR | an error occurred sending the data |
ZSOCKET-SEND-DATA-ERROR | an argument was included that was not a string or binary object |
ZSOCKET-TIMEOUT-ERROR | thrown if a timeout error occurs |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
nothing Qore::ZMQ::ZSocket::send | ( | Qore::ZMQ::ZFrame | frame, |
int | flags = 0 |
||
) |
Sends the given frame over the socket; the frame is consumed by this call unless Qore::ZMQ::ZFRAME_REUSE is used in the flags argument.
frame | the frame to send; if does not contain Qore::ZMQ::ZFRAME_REUSE, the argument object will be deleted by this call; if the frame is empty then no data is sent |
flags | a bitwise-or combination of zero or more of ZFrame Send Flags; to send a frame in non-blocking mode, use the Qore::ZMQ::ZFRAME_DONTWAIT flag |
ZSOCKET-SEND-ERROR | thrown if an error occurs during the call |
ZSOCKET-SEND-WAIT-ERROR | if the Qore::ZMQ::ZFRAME_DONTWAIT flag is used and the message cannot be queued on the socket, this exception is thrown |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
nothing Qore::ZMQ::ZSocket::send | ( | Qore::ZMQ::ZMsg | msg | ) |
Sends the given message over the socket; the message is consumed by this call.
msg | the message to send; the argument object will be deleted as it is consumed by this call; if the message is empty then no data is sent, but the object is destroyed in any case |
ZSOCKET-SEND-ERROR | thrown if an error occurs during the call |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
nothing Qore::ZMQ::ZSocket::setIdentity | ( | string | id | ) |
Sets the socket identity string.
id | the identity string to set on the socket; the string will be converted to UTF-8 encoding if necessary; cannot be an empty string or a ZSOCKET-SETIDENTITY-ERROR exception will be thrown |
ENCODING-CONVERSION-ERROR | this exception could be thrown if an encoding error is encountered when converting the given string to UTF-8 |
ZSOCKET-SETIDENTITY-ERROR | if an error occurs setting the identity option on the socket |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
REQ
REP
DEALER
ROUTER
Qore::ZMQ::ZSocket::setOption | ( | int | opt, |
bool | value | ||
) |
Sets the given socket option to the given value.
opt | the option code; see ZSocket Options for possibile values |
value | the boolean value for the option; this method variant processes options that take boolean values |
If any errors occur setting the option, an exception is raised.
ZSOCKET-OPTION-ERROR | unknown option or invalid value type |
ZSOCKET-SETOPTION-ERROR | error setting option |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
Qore::ZMQ::ZSocket::setOption | ( | int | opt, |
data | value | ||
) |
Sets the given socket option to the given value.
opt | the option code; see ZSocket Options for possibile values |
value | the binary or string value for the option; this method variant processes options that take binary or string values |
If any errors occur setting the option, an exception is raised.
ZSOCKET-OPTION-ERROR | unknown option or invalid value type |
ZSOCKET-SETOPTION-ERROR | error setting option |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
Qore::ZMQ::ZSocket::setOption | ( | int | opt, |
int | value | ||
) |
Sets the given socket option to the given value.
opt | the option code; see ZSocket Options for possibile values |
value | the integer value for the option; this method variant processes options that take integer values |
If any errors occur setting the option, an exception is raised.
ZSOCKET-OPTION-ERROR | unknown option or invalid value type |
ZSOCKET-SETOPTION-ERROR | error setting option |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
nothing Qore::ZMQ::ZSocket::setRecvHighWaterMark | ( | int | value | ) |
Sets the receive high water mark.
value | the "high water mark" value which is a hard limit on the maximum number of outstanding messages ØMQ shall queue in memory for any single peer that the specified socket is communicating with; a value of zero means no limit |
If this limit has been reached the socket shall enter an exceptional state and depending on the socket type, ØMQ shall take appropriate action such as blocking or dropping sent messages. Refer to the individual socket descriptions for details on the exact action taken for each socket type.
0MQ Socket Option Information
Property | Description |
Option value type | int |
Option value unit | messages |
Default value | 1000 |
Applicable socket types | all |
ZSOCKET-SETRECVHIGHWATERMARK-ERROR | if an error occurs setting the timeout option |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a non-thread-safe socket and a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
nothing Qore::ZMQ::ZSocket::setRecvTimeout | ( | timeout | timeout_ms | ) |
Sets the receive timeout in milliseconds.
timeout_ms | set the receive timeout in milliseconds; negative values mean to never time out; like all Qore functions and methods taking timeout values, a relative date/time value can be used to make the units clear (i.e. 2m = two minutes, etc.) |
ZSOCKET-SETRECVTIMEOUT-ERROR | if an error occurs setting the timeout option |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
nothing Qore::ZMQ::ZSocket::setSendTimeout | ( | timeout | timeout_ms | ) |
Sets the send timeout in milliseconds.
timeout_ms | set the send timeout in milliseconds; negative values mean to never time out; like all Qore functions and methods taking timeout values, a relative date/time value can be used to make the units clear (i.e. 2m = two minutes, etc.) |
ZSOCKET-SETSENDTIMEOUT-ERROR | if an error occurs setting the timeout option |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
nothing Qore::ZMQ::ZSocket::setTimeout | ( | timeout | timeout_ms | ) |
Sets the send and receive timeout in milliseconds.
timeout_ms | set the send and receive timeout in milliseconds; negative values mean to never time out; like all Qore functions and methods taking timeout values, a relative date/time value can be used to make the units clear (i.e. 2m = two minutes, etc.) |
ZSOCKET-SETTIMEOUT-ERROR | if an error occurs setting the timeout option |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
string Qore::ZMQ::ZSocket::type | ( | ) |
Returns the socket type as a string.
nothing Qore::ZMQ::ZSocket::unbind | ( | string | format, |
... | |||
) |
Unbinds the socket from a formatted endpoint.
format | the format string for the endpoint |
... | optional arguments for the format string |
Throws an exception if the endpoint was invalid or the function isn't supported on the current socket
ZSOCKET-UNBIND-ERROR | thrown if the endpoint was invalid or the function isn't supported on the current socket |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
nothing Qore::ZMQ::ZSocket::waitRead | ( | timeout | timeout_ms | ) |
Waits for data to read on the socket; if data does not arrive before the timeout expires, a ZSOCKET-TIMEOUT-ERROR
exception is thrown.
timeout_ms | the timeout in milliseconds |
ZSOCKET-TIMEOUT-ERROR | this exception is thrown if data does not arrive before the timeout expires |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |
nothing Qore::ZMQ::ZSocket::waitWrite | ( | timeout | timeout_ms | ) |
Waits for data to be written on the socket; if data is not sent before the timeout expires, a ZSOCKET-TIMEOUT-ERROR
exception is thrown.
timeout_ms | the timeout in milliseconds |
ZSOCKET-TIMEOUT-ERROR | this exception is thrown if the data is not sent before the timeout expires |
ZSOCKET-THREAD-ERROR | this exception is thrown if this method is called from a thread other than the thread where the object was created |
ZSOCKET-CONTEXT-ERROR | the context is no longer valid |