Binds the socket to the network interface using a local endpoint, so that the socket will accept incoming connections on this endpoint:
CALL socket_name.Bind("tcp://*:5555")
Endpoint is a string consisting of a transport :// specifying what protocol to use and the address specifying what transport-specific address to bind to.
Possible transports include tcp, ipc, inproc, and pgm/epgm.
After bind(), sockets enter the mute state and block or drop messages (depending on the socket type).
Variable data type: STRING
Default value: —
Compatible sockets: any
Unbinds the socket from the network interface:
CALL socket_name.Unbind("tcp://*:5555")
Variable data type: STRING
Default value: —
Compatible sockets: any
Explicitly destroys the specified socket:
CALL socket_name.Close()
Any outstanding messages physically received from the network but not yet received by the application are cancelled what is to be done to messages sent via send() but not physically transferred to the network.
By default, setLinger() doesn't cancel unsent messages. However, in such a case application may be blocked if term() is called.
Variable data type: —
Default value: —
Compatible sockets: any
Connects the socket to a remote application and then accepts incoming connections from this application:
CALL socket_name.Connect("tcp://localhost:5556")
Endpoint is a string consisting of a transport :// specifying what protocol to use and the address specifying what transport-specific address to bind to.
Possible transports include tcp, ipc, inproc, and pgm/epgm.
With most transports and socket types, connection is not performed immediately but when needed by ZMQ. Thus, a successful call to connect() doesn't necessarily mean that the connection was or can actually be established. That is why most transports and socket types pay no attention to the order in which server sockets were bound and client sockets were connected. The exceptions to this rule include the inproc transport type which require binding before connecting and ZMQ.PAIR sockets which do not automatically connect to endpoints.
After connect(), sockets enter their normal ready state (except for ZMQ.ROUTER sockets which enter their normal ready state for a specific peer only after handshaking is complete for that peer.
Variable data type: STRING
Default value: —
Compatible sockets: any
Disconnects the socket from a remote application:
CALL socket_name.Disconnect("tcp://localhost:5556")
Variable data type: STRING
Default value: —
Compatible sockets: any
Enables sending messages:
CALL socket_name.Send(msg_var)
CALL socket_name.Send("Your message")
After the successful send() call, messages are queued to the socket (however, it doesn't mean that they were successfully transmitted to the network).
Sending multi-part messages requires sendMore() to enable sending all the message parts but not only the final one.
Variable data type: any
Default value: —
Compatible sockets: any
Specifies that the message sent is a multi-part message and further message parts will follow:
CALL socket_name.SendMore(msg_var)
CALL socket_name.SendMore("Your message")
As ZMQ messages can consist of more than 1 parts, atomic delivery of messages is ensured. However, any peer will receive either all message parts or none at all. Total number of message parts is limited only by the available memory.
Variable data type: any
Default value: —
Compatible sockets: any
Enables receiving messages:
LET zmq_var = socket_name.Recv()
Receiving multi-part messages requires hasReceiveMore() to tell that there are more message parts to come.
Return data type: any
Default value: —
Compatible sockets: any
Specifies that the message received is a multi-part message and further message parts will come:
LET zmq_var = socket_name.HasReceiveMore()
Return data type: BOOLEAN
Default value: —
Compatible sockets: any
Sets the i/o thread affinity for all the newly created connections on the specified socket:
CALLsocket_name.SetAffinity(3)
Affinity determines what thread from the ZMQ i/o thread pool (associated with the socket's context) will handle the newly created connection.
The default value of 0 means that all the messaging will be fairly distributed between all the ZMQ i/o threads in the thread pool (no affinity).
With values other that 0, the lowest bit corresponds to thread 1, second lowest bit to thread 2 and so on. For example, a value of 3 specifies that subsequent connections on socket shall be handled exclusively by I/O threads 1 and 2.
Variable data type: INTEGER
Default value: 0
Compatible sockets: —
Retrieves the i/o thread affinity for all the newly created connections on the specified socket:
LET zmq_var = socket_name.GetAffinity()
Returned data type: INTEGER
Default value: 0
Compatible sockets: —
Sets the maximum length of the queue of outstanding connections for the specified socket:
CALLsocket_name.SetBacklog(15)
Variable data type: INTEGER
Default value: 100
Compatible sockets: any, only for connection-oriented transports
Retrieves the maximum length of the queue of outstanding connections for the specified socket:
LET zmq_var = socket_name.GetBacklog()
Returned data type: INTEGER
Default value: 100
Compatible sockets: any, only for connection-oriented transports
Keeps only one message in the inbound/outbound queue (the latest one received or prepared for sending):
CALLsocket_name.SetConflate(1)
Does not support multi-part messaging. Ignores setRcvHWM() and setSndHWM() methods.
Variable data type: INTEGER
Default value: 0 (false)
Compatible sockets: ZMQ.PULL, ZMQ.PUSH, ZMQ.PUB, ZMQ.SUB, ZMQ.DEALER
Sets the current CURVE public key for the socket.
This key is a STRING of a Z85 encoded data up to 41 characters long.
Public keys must be used with matching secret keys. Public + secret key pairs are generated by the generateKeyPair() method.
Variable data type: STRING
Default value: NULL
Compatible sockets: any when using tcp
Sets the current CURVE secret key for the socket.
This key is a STRING of a Z85 encoded data up to 41 characters long.
Secret keys must be used with matching public keys. Public + secret key pairs are generated by the generateKeyPair() method.
Variable data type: STRING
Default value: NULL
Compatible sockets: any when using tcp
When set to 1, makes the socket act as a CURVE server:
CALLsocket_name.SetCurveServer(1)
Resetting setCurveServer()to 0 resets socket security to NULL.
Making a socket a CURVE server requires setting the CURVE secret key.
Server sockets do not need to know their public keys.
Variable data type: BOOLEAN
Default value: 0
Compatible sockets: any when using tcp
Retrieves the event state of the specified socket:
LET zmq_var = socket_name.GetEvents()
Returns a numeric value which is the combination of the following flags :
ZMQ.POLLIN indicating that at least one message may be received from the specified socket without blocking,
ZMQ.POLLOUT indicating that at least one message may be sent to the specified socket without blocking.
Returned data type: INTEGER
Default value: —
Compatible sockets: any
Retrieves the file descriptor associated with the specified socket:
LET zmq_var = socket_name.GetFD()
Returned file descriptors are used to integrate the socket into the existing event loop: ZMQ library signals about any pending events on the socket in an edge-triggered fashion by making the file descriptor become ready for reading.
The fact that the returned file descriptor can be read from doesn't necessarily mean that messages can be read from (or written to) the underlying socket: getEvents() must be used to retrieve the actual event state .
Returned file descriptors are used internally by the send() and recv() methods for updating the event state after the corresponding calls.
Returned file descriptors are intended to be used only with polling or similar calls. Applications must never attempt to read or write data directly to file descriptors or try to close them.
Returned data type: INTEGER
Default value: —
Compatible sockets: any
Sets the identity of the specified socket when connecting to a ZMQ.ROUTER socket.
If several clients use the same identity when connecting to a ZMQ.ROUTER socket, the socket will accept only the first client and reject all the others.
Variable data type: DYNAMIC ARRAY of INTEGER
Default value: NULL
Compatible sockets: ZMQ.REP, ZMQ.REQ, ZMQ.ROUTER, ZMQ.DEALER
Retrieves the identity of the specified socket:
LET zmq_var = socket_name.GetIdentity()
Socket identity is used only for request/reply: E.g. it is used with ZMQ.ROUTER sockets to route messages to the peer with the specific identity.
Returned data type: DYNAMIC ARRAY of INTEGER
Default value: NULL
Compatible sockets: ZMQ.REP, ZMQ.REQ, ZMQ.ROUTER, ZMQ.DEALER
Sets the IPv6 override status to a socket:
CALLsocket_name.SetIPv6(1)
When setIPv6() is set to 0, the socket will connect to, or accept connections from, IPv4 hosts only. When setIPv6() is set to 1, the socket will connect to, or accept connections from, both IPv4 and IPv6 hosts.
Variable data type: BOOLEAN
Default value: 0 (false)
Compatible sockets: any when using tcp
Enables queueing messages only to completed connections:
CALL socket_name.SetImmediate(1)
By default, messages are queued on the outgoing connections even if the connection is not completed. That is why messages are sometimes lost on sockets providing round-robin routing (ZMQ.REQ, ZMQ.PUSH, ZMQ.DEALER). With setImmediate()set to 1, messages will be queued only to completed connections and sockets will block messaging if no connections are available.
Variable data type: BOOLEAN
Default value: 0 (false)
Compatible sockets: any, only for connection-oriented transports
Retrieves the latest endpoint bound for tcp or ipc transports:
LET zmq_var = socket_name.GetLastEndpoint()
Returned value is a string in the form of a ZMQ DSN. When the interface is specified by * (meaning that any of the available interfaces can be used), the method will return 0.0.0.0 (for IPv4).
Returned data type: STRING
Default value: NULL
Sets linger period for the specified socket:
CALL socket_name.SetLinger(10000)
Linger period determines for how long messages to be sent will linger in memory after a socket is closed with close().
By default, linger period is infinite, messages are not canceled after close() is called, and the context will not be terminated with term() until all the messages are sent.
With setLinger()set to 0, there is no linger period, and messages are canceled immediately after close() is called.
With setLinger() set to any positive, linger period lasts for the number of milliseconds equal to this value, messages are not canceled after close() is called, and the context will not be terminated with term() until all the messages are sent or the linger period expires. After the linger period expires, all the remaining messages are canceled.
Variable data type: INTEGER
Default value: -1
Compatible sockets: any
Retrieves linger period for the specified socket:
LET zmq_var = socket_name.GetLinger()
Returned data type: INTEGER
Default value: -1
Compatible sockets: any
Sets maximal acceptable size (in bytes) for inbound messages:
CALLsocket_name.SetMaxMsgSize(1024)
If the sent message is longer that specified by setMaxMsgSize(), the peer is disconnected.
By default, there are no size limits.
Variable data type: INTEGER
Default value: -1
Compatible sockets: any
Retrieves the maximal acceptable size for inbound messages:
LET zmq_var = socket_name.GetMaxMsgSize()
Returned data type: INTEGER
Default value: -1
Compatible sockets: any
Sets maximal network hops for multicast packets:
CALL socket_name.SetMulticastHops(1000)
By default, multicast packets don't leave the local network.
Variable data type: INTEGER
Default value: 1
Compatible sockets: any, when using multicast transports
Retrieves the maximal network hops for multicast packets:
LET zmq_var = socket_name.GetMulticastHops()
Returned data type: INTEGER
Default value: 1
Compatible sockets: any, when using multicast transports
Sets a user name for the PLAIN server:
CALL socket_name.SetPlainUserName("client")
With setPlainUserName() set to NULL, the security mechanism used for connections will be NULL. With setPlainUserName() set to any non-null value, the security mechanism used for connections will be PLAIN.
Variable data type: STRING
Default value: not set
Compatible sockets: any when using tcp
Retrieves the current user name set for the PLAIN server:
LET zmq_var = socket_name.GetPlainUserName()
Returned value must be a NULL-terminated string (may be empty) and must include the terminating null byte.
Returned data type: STRING
Default value: NULL string
Sets a password for the PLAIN server:
CALL socket_name.SetPlainSPassword("informix")
With setPlainPassword() set to NULL, the security mechanism used for connections will be NULL. With setPlainPassword() set to any non-null value, the security mechanism used for connections will be PLAIN.
Variable data type: STRING
Default value: not set
Compatible sockets: any when using tcp
Retrieves the current password set for the PLAIN server:
LET zmq_var = socket_name.GetPlainPassword()
Returned value must be a NULL-terminated string (may be empty) and must include the terminating null byte.
Returned data type: STRING
Default value: NULL string
Enables bootstrap connection to ZMQ.Router sockets:
CALL socket_name.SetProbeRouter(TRUE)
With setProbeRouter() set to true, the socket will automatically send an empty message when a new connection is made or accepted, signalling that a new peer has arrived.
Can be set only for ZMQ.REQ, ZMQ.ROUTER, and ZMQ,DEALER sockets; otherwise, will lead to unexpected results.
Variable data type: BOOLEAN
Default value: false
Compatible sockets: ZMQ.REQ, ZMQ.ROUTER, ZMQ.DEALER
Sets the data rate for multicast transports which use the specified socket:
CALL socket_name.SetRate(75)
Variable data type: INTEGER
Default value: 100
Compatible sockets: any, when using multicast transports
Retrieves the data rate for multicast transports which use the specified socket:
LET zmq_var = socket_name.GetRate()
Returned data type: INTEGER
Default value: 100
Compatible sockets: any, when using multicast transports
Sets the upper limit defined for inbound messages on the specified socket:
CALL socket_name.SetRcvHWM(750)
setRcvHWM() specifies the maximum number of inbound messages which will be queued in memory for any single peer.
With setRcvHWM()set to 0, there is no limit.
When this limit is reached, the socket will enter an exceptional state and block or drop sending messages (depending on the socket type).
Variable data type: INTEGER
Default value: 1000
Compatible sockets: any
Retrieves the upper limit defined for inbound messages on the specified socket:
LET zmq_var = socket_name.GetRcvHWM()
Returned data type: INTEGER
Default value: 1000
Compatible sockets: any
Sets the kernel receive buffer size for the specified socket:
CALL socket_name.SetReceiveBufferSize(1024)
By default, the kernel receive buffer size remains the one specified by the operating system.
Variable data type: INTEGER
Default value: 0
Compatible sockets: any
Retrieves the kernel receive buffer size for the specified socket:
LET zmq_var = socket_name.GetReceiveBufferSize()
Returned data type: INTEGER
Default value: 0
Compatible sockets: any
Sets the maximal time (in milliseconds) of waiting for a coming message before the socket returns an EAGAIN error:
CALL socket_name.SetReceiveTimeOut(15)
With setReceiveTimeOut() set to 0, an EAGAIN error is returned immediately if there are no messages to receive. With setReceiveTimeOut() set to -1, the socket will block until any messages are available. With setReceiveTimeOut() set to any other value, the socket will return an EAGAIN error after waiting for the number of milliseconds equal to this value.
Variable data type: INTEGER
Default value: -1 (infinite)
Compatible sockets: any
Retrieves the maximal time of waiting for a coming message before the socket operation returns the EAGAIN error:
LET zmq_var = socket_name.GetReceiveTimeOut()
Returned data type: INTEGER
Default value: -1 (infinite)
Compatible sockets: any
Sets the reconnection interval (in milliseconds) for the specified socket:
CALL socket_name.SetReconnectIVL(5)
Reconnection interval is the period for which ZMQ will wait between the attempts to reconnect to a disconnected peer when using connection-oriented transports. With setReconnectIVL() set to -1, there is no reconnection.
Reconnection intervals may be randomized by ZMQ in order to prevent reconnection storms in topologies for the sockets which have a large number of peers.
Variable data type: INTEGER
Default value: 100
Compatible sockets: any, only for connection-oriented transports
Returns the reconnection interval for the specified socket:
LET zmq_var = socket_name.GetReconnectIVL()
Returned data type: INTEGER
Default value: 100
Compatible sockets: any, only for connection-oriented transports
Sets the maximal reconnection interval (in milliseconds) for the specified socket:
CALL socket_name.SetReconnectIVLMax(25)
Maximal reconnection interval is the maximal period for which ZMQ will wait between the attempts to reconnect to a disconnected peer when using connection-oriented transports. With every attempt to reconnect, the reconnection period doubles until the maximal reconnection interval is reached (exponential backoff strategy). By default, no exponential backoff is performed and reconnection interval is calculated based on the value set for setReconnectIVL().
Values smaller than the value set for setReconnectIVL() are ignored.
Variable data type: INTEGER
Default value: 0
Compatible sockets: any, only for connection-oriented transports
Returns the maximal reconnection interval for the specified socket:
LET zmq_var = socket_name.GetReconnectIVLMax()
Returned data type: INTEGER
Default value: 0
Compatible sockets: any, only for connection-oriented transports
Sets the recovery interval (in milliseconds) for multicast transports using the specified socket:
CALL socket_name.SetRecoveryInterval(15)
Recovery interval determines the maximal time (in milliseconds) within that a receiver can be absent from a multicast group before unrecoverable data loss occurs.
Large recovery intervals secure that no data are lost for a considerably long periods of time but set certain requirements for the used hardware (as the necessary data is kept in memory). E.g. you need a 7GB in-memory buffer if you set the recovery interval for 1 minute at the data rate of 1Gbps requires .
Variable data type: INTEGER
Default value: 10000
Compatible sockets: any, when using multicast transports
Returns the recovery interval for multicast transports using the specified socket:
LET zmq_var = socket_name.GetRecoveryInterval()
Returned data type: INTEGER
Default value: 10000
Compatible sockets: any, when using multicast transports
Forces matching of requests and replies by adding a request id as a prefix to any outgoing message (for ZMQ.REQ sockets only:
CALL socket_name.SetReqCorrelate(1)
With setReqCorrelate() set to 1, all the messages without such a prefix are cancelled
Variable data type: BOOLEAN
Default value: 0
Compatible sockets: ZMQ.REQ
Allows initiating a new requests before the ZMQ.REQ socket has received a reply to the previous one (is not allowed by default):
CALL socket_name.SetReqRelaxed(1)
When setReqRelaxed() is set to 1 and sending another message is allowed, the ZMQ.REQ socket disconnects from the peer which has to reply, request-reply machine is reset, and a new request is sent to the next available peer.
Requires setReqCorrelate() to be set in order to ensure that requests and replies are properly matched. Otherwise, a late reply to an aborted request can be reported as a reply to the superseding request.
Variable data type: BOOLEAN
Default value: 0
Compatible sockets: ZMQ.REQ
Specifies how ZMQ.ROUTER sockets will react to unroutable messages:
CALL socket_name.SetRouterMandatory(1)
By default, all unroutable messages are silently cancelled. When setRouterMandatory() is set to 1, all unroutable messages cause an EHOSTUNREACH error.
Variable data type: BOOLEAN
Default value: 0
Compatible sockets: ZMQ.ROUTER
Switches ZMQ.ROUTER sockets to the raw mode:
CALL socket_name.SetRouterRaw(1)
When a ZMQ.ROUTER socket is in raw mode,
Variable data type: BOOLEAN
Default value: 0
Compatible sockets: ZMQ.ROUTER
Sets the kernel transmit buffer size for the specified socket:
CALL socket_name.SetSendBufferSize(1024)
By default, the kernel transmit buffer size remains the one specified by the operating system.
Variable data type: INTEGER
Default value: 0
Compatible sockets: any
Retrieves the kernel transmit buffer size for the specified socket:
LET zmq_var = socket_name.GetSendBufferSize()
Returned data type: INTEGER
Default value: 0
Compatible sockets: any
Sets the maximal time (in milliseconds) of waiting for sending a message before the socket returns an EAGAIN error:
CALL socket_name.SetSendTimeOut(15)
With setSendTimeOut() set to 0, an EAGAIN error is returned immediately if the message cannot be sent. With setSendTimeOut() set to -1, the socket will block until the message is sent. With setSendTimeOut() set to any other value, the socket will try to send the message for the number of milliseconds equal to this value before returning an EAGAIN error.
Variable data type: INTEGER
Default value: -1 (infinite)
Compatible sockets: any
Retrieves the maximal time of waiting for sending a message before the socket returns an EAGAIN error:
LET zmq_var = socket_name.GetSendTimeOut()
Returned data type: INTEGER
Default value: -1 (infinite)
Compatible sockets: any
Sets the upper limit defined for outbound messages on the specified socket:
CALL socket_name.SetSndHWM(750)
setSndHWM() specifies the maximum number of outstanding messages which will be queued in memory for any single peer.
With setSndHWM() set to 0, there is no limit.
When this limit is reached, the socket will enter an exceptional state and block or drop sending messages (depending on the socket type).
Variable data type: INTEGER
Default value: 1000
Compatible sockets: any
Retrieves the upper limit defined for outbound messages on the specified socket:
LET zmq_var = socket_name.GetSndHWM()
Returned data type: INTEGER
Default value: 1000
Compatible sockets: any
Assigns an arbitrary number of filters to be applied to every new TCP transport connection on a listening socket:
CALL request.SetTCPAcceptFilter("localhost/11")
or
CALL request.SetTCPAcceptFilter("<ip_as_cidr")
where the filter (i.e. ip_as_cidr) is a null-terminated string with IPv6 or IPv4 represented as a CIDR notation.
If no filters are applied, tcp transport allows connections from any IP address. If any filters are applied, then the transport will allow connecting only to IP addresses which match the filter.
Variable data type: STRING
Default value: no filters
Compatible sockets: any listening socket when using tcp or ipc
Retrieves the type of the specified socket:
LET zmq_var = socket_name.GetType()
Socket type is specified when the ZMQ.Socket object is created and cannot be changed afterwards.
Returned data type: INTEGER
Default value: —
Compatible sockets: any
Sets the RFC 27 authentication domain for the socket.
For NULL security, ZAP authentication is needed only if you set a non-empty domain. For PLAIN and CURVE security, ZAP requests are made every time then there is a ZAP handler.
Variable data type: STRING
Default value: not set
Compatible sockets: any when using tcp
Specifies how ZMQ.XPUB sockets will react to new subscriptions and unsubscriptions:
CALL socket_name.SetXPubVerbose(1)
By default, only new subscription messages go upstream. When setXPubVerbose() is set to 1, all subscription messages go upstream.
Variable data type: INTEGER
Default value: 0
Compatible sockets: ZMQ.XPUB
Establishes new message filters on ZMQ.SUB sockets.
Newly created ZMQ.SUB sockets filter out all incoming messages, so you need to set certain filters to be able to get messages.
With subscribe() set to 0, a ZMQ.SUB socket will subscribe to all incoming messages. With subscribe() set to any non-zero value, a ZMQ.SUB socket will subscribe only to messages which have the specified prefix.
Multiple filtering is possible for ZMQ.SUB sockets: In this case, a message is accepted if it matches at least one filter.
Variable data type: STRING
Default value: —
Compatible sockets: ZMQ.SUB
Removes the message filters established on a ZMQ.SUB socket:
CALL socket_name.Unsubscribe()
If the socket has several instances of the same filter attached to it, unsubscribe() will remove only one instance, leaving all the other instance functional.
Variable data type: STRING
Default value: —
Compatible sockets: ZMQ.SUB
Unicast transport using the TCP protocol.
With the tcp transport, endpoints are interpreted as interfaces.
As an interface, it is specified by either of these variants:
TCP port number is specified by:
When using ephemeral ports, callers retrieve the actual assigned port using the getLastEndpoint() method.
When sockets are connected to peer addresses using connect() with a tcp transport, peer addresses are specified by either of these variants:
Local inter-process communication transport.
With the ipc transport, endpoints are interpreted as arbitrary strings identifying names of the path to be created. The path name must be unique and must conform all the restrictions imposed by the OS. Endpoint paths which names start with / are interpreted as absolute paths. If the specified endpoint path doesn't exit, the bind will fail.
If the address is specified by *, a unique temporary path name will be generated. This path name must be retrieved by the caller using the getLastEndpoint() method.
Bindings to the same endpoint are overridden: If a process binds to the endpoint already bound to any other process, this second process will succeed, and the first one will lose its binding. Here, the ipc behavior disagrees with tcp and inproc.
When sockets are connected to peer addresses using connect() with an ipc transport, the path name must be previously created within the OS by assigning it to a socket via bind().
Local in-process (inter-thread) communication transport.
With the inproc transport, endpoints are interpreted as arbitrary strings identifying names to be created. The name must be unique within the ZMQ context associated with the socket and can be up to 256 characters long.
When sockets are connected to peer addresses using connect() with an inproc transport, the name must be previously created by assigning it to at least one socket within the same ZMQ context as the to-be-connected socket.
Reliable multicast transports using the PGM protocol.
With the pgm/epgm transport, endpoints are interpreted as interfaces and include a semicolon, followed by a multicast address, a colon, and a port number.
pgm requires access to raw IP sockets as well as certain other rights (depending on the OS). If an application doesn't require direct interoperability with other pgm implementations, it is better to use epgm instead.
pgm and epgm transports can only be used with ZMQ.PUB and ZMQ.SUB sockets.
When sockets are connected to peer addresses using connect() with a pgm/epgm transport, peer addresses are specified by either of these variants:
Multicast addresses are specified as IPv4 multicast addresses in their numeric representation.
You can find more details about pgm and epgm transport types here.