Qore zmq Module  1.0.0
Qore::ZMQ::ZSocket Class Referenceabstract

The ZSocket class provides the abstract base class for ZeroMQ socket classes. More...

Inheritance diagram for Qore::ZMQ::ZSocket:
Qore::ZMQ::ZSocketDealer Qore::ZMQ::ZSocketPair Qore::ZMQ::ZSocketPub Qore::ZMQ::ZSocketPull Qore::ZMQ::ZSocketPush Qore::ZMQ::ZSocketRep Qore::ZMQ::ZSocketReq Qore::ZMQ::ZSocketRouter Qore::ZMQ::ZSocketStream Qore::ZMQ::ZSocketSub Qore::ZMQ::ZSocketXPub Qore::ZMQ::ZSocketXSub

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...
 

Detailed Description

The ZSocket class provides the abstract base class for ZeroMQ socket classes.

Restrictions:
Qore::PO_NO_NETWORK

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:

sock.setTimeout(-1);
Note
  • The ZSocket class is not designed to be accessed from multiple threads; it was created without locking for fast and efficient use when used from a single thread. For methods that would be unsafe to use in another thread, any use of such methods in threads other than the thread where the constructor was called will cause a ZSOCKET-THREAD-ERROR to be thrown.

Member Function Documentation

◆ attach()

nothing Qore::ZMQ::ZSocket::attach ( *string  endpoints,
bool  do_bind = False 
)

Attaches the socket to zero or more endpoints.

Examples:
zsock.attach(endpoints_str, True);
Parameters
endpointszero or more endpoints, separated by commas and prefixed by '@' (to bind the socket) or '>' (to connect the socket)
do_binddetermines 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

Exceptions
ZSOCKET-CONNECT-ERRORthrown if there is a connect error
ZSOCKET-BIND-ERRORthrown if there is a bind error
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

◆ bind()

int Qore::ZMQ::ZSocket::bind ( string  format,
  ... 
)

Bind the ZSocket to a formatted endpoint.

Examples:
# bind to a random port
int port = zsock.bind("tcp://127.0.0.1:*");
# bind to a random port
port = zsock.bind("tcp://127.0.0.1:0");

For tcp:// endpoints, this class supports binding on a random free port if you specify the port number as "*" or \ "0".

Parameters
formatthe format string for the endpoint
...optional arguments for the format string
Returns
the actual port number used for "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.
Exceptions
ZSOCKET-BIND-ERRORif an error occurs, this exception is thrown
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
Note
do not use the endpoint prefix "@" with this method

◆ connect()

nothing Qore::ZMQ::ZSocket::connect ( string  format,
  ... 
)

Connects the socket to a formatted endpoint.

Examples:
zsock.unbind(str);
Parameters
formatthe format string for the endpoint
...optional arguments for the format string

Throws an exception if an error occurs connecting to the endpoint

Exceptions
ZSOCKET-CONNECT-ERRORthrown if an error occurs connecting to the endpoint
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid
Note
do not use the endpoint prefix ">" with this method

◆ copy()

Qore::ZMQ::ZSocket::copy ( )

Throws an exception; copying ZSocket objects is not currently supported.

Exceptions
ZSOCKET-COPY-ERRORcopying ZSocket objects is not currently supported

◆ disconnect()

nothing Qore::ZMQ::ZSocket::disconnect ( string  format,
  ... 
)

Disconnects the socket from a formatted endpoint.

Examples:
zsock.disconnect(str);
Parameters
formatthe 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

Exceptions
ZSOCKET-DISCONNECT-ERRORthrown if the endpoint was invalid or the function isn't supported on the current socket
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

◆ endpoint()

*string Qore::ZMQ::ZSocket::endpoint ( )

Returns the last bound endpoint, if any or nothing if not.

Code Flags:
CONSTANT
Examples:
*string endpoint = zsock.endpoint();
Returns
the last bound endpoint, if any or nothing if not
Exceptions
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created

◆ getIdentity()

*string Qore::ZMQ::ZSocket::getIdentity ( )

retrieves the socket identity string

Code Flags:
CONSTANT
Example:
*string id = zsock.getIdentity();
Returns
the socket identity string or nothing if no value is set
Exceptions
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created

◆ getOption()

auto Qore::ZMQ::ZSocket::getOption ( int  opt,
int  bufsize = 100 
)

Retrieves the value of the given socket option.

Code Flags:
RET_VALUE_ONLY
Examples:
int v = zsock.getOption(ZMQ_RCVHWM);
Parameters
optthe option code; see ZSocket Options for possibile values
bufsizethe size of the buffer for string and binary options
Returns
the value for the option; the return type depends on the option

If any errors occur retrieving the option, an exception is raised.

Exceptions
ZSOCKET-OPTION-ERRORunknown option
ZSOCKET-GETOPTION-ERRORerror setting option
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

◆ monitor()

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.

Examples:
zsock.monitor(ZMQ_EVENT_ALL, "inproc://monitor-socket-1");
Parameters
eventsan event code mask combined with binary or; see ZSocket Events for possible values
formatthe format string for the endpoint, which must be an "inproc://" endpoint
...optional arguments for the format string
Exceptions
ZSOCKET-MONITOR-ERRORthis exception is thrown if the internal call to zmq_socket_monitor() fails
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid
Note
This method supports only "inproc://" endpoints

◆ poll()

static list<hash<ZmqPollInfo> > Qore::ZMQ::ZSocket::poll ( list< hash< ZmqPollInfo >>  items,
timeout  timeout_ms 
)
static

polls multiple sockets and returns all sockets with events

Example:
list<hash<ZmqPollInfo>> l(
new hash<ZmqPollInfo>(()),
new hash<ZmqPollInfo>(()),
);
l = ZSocket::poll(l, 2s);
Parameters
itemlist of ZmqPollInfo hashes
timeout_msthe poll timeout period
Returns
a list of sockets with events in the timeout period
Exceptions
ZSOCKET-POLL-ERRORsocket element in the items argument is not assigned or there was an error in the poll operation
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

◆ proxy()

static nothing Qore::ZMQ::ZSocket::proxy ( ZSocket  frontend,
ZSocket  backend,
*ZSocket  capture 
)
static

starts the built-in ZeroMQ proxy to connect messages between two sockets

Example:
ZSocketDealer frontend(zctx2, "dealer-1", "@tcp://127.0.0.1:*");
ZSocketRouter backend(zctx2, "router-1", ">" + writer.endpoint());
ZSocket::proxy(frontend, backend);
Parameters
frontendthe frontend socket for the proxy
backendthe backend socket for the proxy
capturean optional capture socket to capture frontend and backend messages
Description
The proxy connects a frontend socket to a backend socket. Conceptually, data flows from frontend to backend. Depending on the socket types, replies may flow in the opposite direction. The direction is conceptual only; the proxy is fully symmetric and there is no technical difference between frontend and backend.

Before calling this method you must set any socket options, and connect or bind both frontend and backend sockets.

This method runs in the current thread and returns only if and when the ZContext object associated with either of the sockets is closed by calling ZContext::shutdown() in another thread.

If the capture socket is not nothing, the proxy shall send all messages received on both frontend and backend to the capture socket. The capture socket should be a PUB, DEALER, PUSH, or PAIR socket.
Example usage
Shared queue
When the frontend is a ROUTER socket, and the backend is a DEALER socket, the proxy shall act as a shared queue that collects requests from a set of clients, and distributes these fairly among a set of services. Requests shall be fair-queued from frontend connections and distributed evenly across backend connections. Replies shall automatically return to the client that made the original request.

Forwarder
When the frontend is a XSUB socket, and the backend is a XPUB socket, the proxy shall act as a message forwarder that collects messages from a set of publishers and forwards these to a set of subscribers. This may be used to bridge networks transports, e.g. read on tcp:// and forward on pgm://.

Streamer
When the frontend is a PULL socket, and the backend is a PUSH socket, the proxy shall collect tasks from a set of clients and forward these to a set of workers using the pipeline pattern.
Exceptions
ZSOCKET-PROXY-ERRORerror executing the proxy call

◆ recvFrame()

ZFrame Qore::ZMQ::ZSocket::recvFrame ( )

Receives a frame from the socket.

Example:
ZFrame frm = zsock.recvFrame();
Returns
the frame received from the socket
Exceptions
ZSOCKET-RECVFRAME-ERRORthrown if an error occurs during the call
ZSOCKET-TIMEOUT-ERRORthrown if a timeout error occurs
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

◆ recvMsg()

ZMsg Qore::ZMQ::ZSocket::recvMsg ( )

Receives a message from the socket.

Example:
ZMsg frm = zsock.recvMsg();
Returns
the messsage received from the socket
Exceptions
ZSOCKET-RECVMSG-ERRORthrown if an error occurs during the call
ZSOCKET-TIMEOUT-ERRORthrown if a timeout error occurs
ZSOCKET-THREAD-ERRORthis 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-ERRORthe context is no longer valid

◆ send() [1/4]

nothing Qore::ZMQ::ZSocket::send ( )

Sends a zero-length message over the socket.

Example:
zsock.send();
Exceptions
ZSOCKET-SEND-ERRORan error occurred sending the data
ZSOCKET-TIMEOUT-ERRORthrown if a timeout error occurs
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid
Note
equivalent to calling ZSocket::send(string) or ZSocket::send(binary) with empty arguments

◆ send() [2/4]

nothing Qore::ZMQ::ZSocket::send ( data  val,
  ... 
)

Sends one or more strings or binary data objects over the socket.

Example:
zsock.send(str1, str2);
Parameters
valthe 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

Exceptions
ZSOCKET-SEND-ERRORan error occurred sending the data
ZSOCKET-SEND-DATA-ERRORan argument was included that was not a string or binary object
ZSOCKET-TIMEOUT-ERRORthrown if a timeout error occurs
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

◆ send() [3/4]

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.

Example:
zsock.send(frame);
Parameters
framethe 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
flagsa 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
Exceptions
ZSOCKET-SEND-ERRORthrown if an error occurs during the call
ZSOCKET-SEND-WAIT-ERRORif the Qore::ZMQ::ZFRAME_DONTWAIT flag is used and the message cannot be queued on the socket, this exception is thrown
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

◆ send() [4/4]

nothing Qore::ZMQ::ZSocket::send ( Qore::ZMQ::ZMsg  msg)

Sends the given message over the socket; the message is consumed by this call.

Example:
zsock.send(msg);
Parameters
msgthe 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
Exceptions
ZSOCKET-SEND-ERRORthrown if an error occurs during the call
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

◆ setIdentity()

nothing Qore::ZMQ::ZSocket::setIdentity ( string  id)

Sets the socket identity string.

Example:
# create an unconnected ROUTER socket
ZSocketRouter router(zctx);
# set the router's identity value explicitly before binding
router.setIdentity(RouterIdentity);
port = router.bind("tcp://127.0.0.1:*");
Parameters
idthe 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
Exceptions
ENCODING-CONVERSION-ERRORthis exception could be thrown if an encoding error is encountered when converting the given string to UTF-8
ZSOCKET-SETIDENTITY-ERRORif an error occurs setting the identity option on the socket
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid
Note
  • the identity takes affect in the next socket connection; if the socket is already connected, then it must be reconnected for the identity value set in this call to take effect
  • it is recommended to use an identity option with the following socket types:
See also
ZMQ_IDENTITY

◆ setOption() [1/3]

Qore::ZMQ::ZSocket::setOption ( int  opt,
bool  value 
)

Sets the given socket option to the given value.

Examples:
zsock.setOption(ZMQ_CURVESERVER, True);
Parameters
optthe option code; see ZSocket Options for possibile values
valuethe 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.

Exceptions
ZSOCKET-OPTION-ERRORunknown option or invalid value type
ZSOCKET-SETOPTION-ERRORerror setting option
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

◆ setOption() [2/3]

Qore::ZMQ::ZSocket::setOption ( int  opt,
data  value 
)

Sets the given socket option to the given value.

Examples:
zsock.setOption(ZMQ_CONNECT_RID, bin);
Parameters
optthe option code; see ZSocket Options for possibile values
valuethe 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.

Exceptions
ZSOCKET-OPTION-ERRORunknown option or invalid value type
ZSOCKET-SETOPTION-ERRORerror setting option
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

◆ setOption() [3/3]

Qore::ZMQ::ZSocket::setOption ( int  opt,
int  value 
)

Sets the given socket option to the given value.

Examples:
zsock.setOption(ZMQ_RCVHWM, 2000);
Parameters
optthe option code; see ZSocket Options for possibile values
valuethe 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.

Exceptions
ZSOCKET-OPTION-ERRORunknown option or invalid value type
ZSOCKET-SETOPTION-ERRORerror setting option
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

◆ setRecvHighWaterMark()

nothing Qore::ZMQ::ZSocket::setRecvHighWaterMark ( int  value)

Sets the receive high water mark.

Example:
zsock.setRecvHighWaterMark(2000);
Parameters
valuethe "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
Exceptions
ZSOCKET-SETRECVHIGHWATERMARK-ERRORif an error occurs setting the timeout option
ZSOCKET-THREAD-ERRORthis 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-ERRORthe context is no longer valid
See also
  • ZSocket::setSendHighWaterMark()

◆ setRecvTimeout()

nothing Qore::ZMQ::ZSocket::setRecvTimeout ( timeout  timeout_ms)

Sets the receive timeout in milliseconds.

Example:
zsock.setRecvTimeout(30s);
Parameters
timeout_msset 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.)
Exceptions
ZSOCKET-SETRECVTIMEOUT-ERRORif an error occurs setting the timeout option
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid
Note
if this method is not called, the default timeout for all send and receive operations when a new socket is created is two minutes
See also

◆ setSendTimeout()

nothing Qore::ZMQ::ZSocket::setSendTimeout ( timeout  timeout_ms)

Sets the send timeout in milliseconds.

Example:
zsock.setSendTimeout(30s);
Parameters
timeout_msset 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.)
Exceptions
ZSOCKET-SETSENDTIMEOUT-ERRORif an error occurs setting the timeout option
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid
Note
if this method is not called, the default timeout for all send and receive operations when a new socket is created is two minutes
See also

◆ setTimeout()

nothing Qore::ZMQ::ZSocket::setTimeout ( timeout  timeout_ms)

Sets the send and receive timeout in milliseconds.

Example:
zsock.setTimeout(30s);
Parameters
timeout_msset 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.)
Exceptions
ZSOCKET-SETTIMEOUT-ERRORif an error occurs setting the timeout option
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid
Note
if this method is not called, the default timeout for all send and receive operations when a new socket is created is two minutes
See also

◆ type()

string Qore::ZMQ::ZSocket::type ( )

Returns the socket type as a string.

Code Flags:
CONSTANT
Example:
string type = zsock.type();
Returns
the socket type as a string

◆ unbind()

nothing Qore::ZMQ::ZSocket::unbind ( string  format,
  ... 
)

Unbinds the socket from a formatted endpoint.

Examples:
zsock.unbind(str);
Parameters
formatthe 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

Exceptions
ZSOCKET-UNBIND-ERRORthrown if the endpoint was invalid or the function isn't supported on the current socket
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

◆ waitRead()

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.

Example:
zsock.waitRead(10s);
Parameters
timeout_msthe timeout in milliseconds
Exceptions
ZSOCKET-TIMEOUT-ERRORthis exception is thrown if data does not arrive before the timeout expires
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

◆ waitWrite()

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.

Example:
zsock.waitWrite(10s);
Parameters
timeout_msthe timeout in milliseconds
Exceptions
ZSOCKET-TIMEOUT-ERRORthis exception is thrown if the data is not sent before the timeout expires
ZSOCKET-THREAD-ERRORthis exception is thrown if this method is called from a thread other than the thread where the object was created
ZSOCKET-CONTEXT-ERRORthe context is no longer valid

The documentation for this class was generated from the following file: