4.1 ZeroMQ functions

4.1.1 iszmq

: tf = iszmq (h)

Determine whether h is a zeromq socket object.

Inputs

h - a potential zeromq socket object to check

Outputs

tf - true if h is a zeromq socket object, otherwise false.

See also: zmq_socket.

4.1.2 zmq_bind

: status = zmq_bind (sock, endpoint)

Bind a zeromq socket to a endpoint.

Inputs

sock - the socket to bind.

endpoint - the endpoint string.

Outputs

status - status for bind. On success, bind will return a status of true

See also: zmq_socket .

4.1.3 zmq_close

: zmq_close (sock)

Close a zeromq socket.

Inputs

sock - the socket type to close.

Outputs

None

See also: zmq_socket .

4.1.4 zmq_connect

: status = zmq_connect (sock, endpoint)

Connect a zeromq socket to a endpoint.

Inputs

sock - the socket to connect.

endpoint - the endpoint string.

Outputs

status - status for connect. On success, connect will return a status of true

See also: zmq_socket.

4.1.5 zmq_curve_keypair

: [ publickey, privatekey ] = zmq_curve_keypair ()

Generate a random private/public keypair

Inputs

None

Outputs

publickey is a string that is the encoded public key

privatekey is a string that is the encoded private key

See also: zmq_z85_encode .

4.1.6 zmq_curve_public

: publickey = zmq_curve_public (privatekey)

Derive the public key from a private key

Inputs

privatekey is a string that is the encoded private key. It must be 40 characters in length

Outputs

publickey is a string that is the encoded public key

See also: zmq_curve_keypair.

4.1.7 zmq_disconnect

: status = zmq_disconnect (sock, endpoint)

Disconnect a zeromq socket from an endpoint.

Inputs

sock - the socket to disconnect from.

endpoint - a previously connected endpoint string to disconnect.

Outputs

status - status for disconnect. On success, disconnect will return a status of true

See also: zmq_socket, zmq_connect.

4.1.8 zmq_errno

: errornum = zmq_errno ()

Get the value of errno from zeromq.

Inputs

None

Outputs

errornum is the errno value of the calling thread.

4.1.9 zmq_getsockopt

: value = zmq_getsockopt (sock, optionid)

Get the current value of an option.

Inputs

sock - the socket to connect.

optionid - the setsockopt option to set.

Valid optionids are:

ZMQ_RCVMORE

Flag for whether a message has been split into multiple messages. The return value will be either 0 or 1.

ZMQ_TYPE

Socket type for zeromq socket created with zmq_socket. Valid types are the same as the socket type value specified with zmq_socket.

ZMQ_EVENTS

Get the event state of zeromq socket. The returned value is a bit mask that may contain the following set values:

  • ZMQ_POLLIN set when at least one message is available to read and zmq_recv will not block.
  • ZMQ_POLLOUT set when at least one message can be written without zmq_send blocking.
ZMQ_IDENTITY or ZMQ_ROUTING_ID

Get the socket identity value

ZMQ_RATE

Get the multicast data rate

ZMQ_PRIORITY

Get socket priority (linux only)

ZMQ_BACKLOG

Get length of queue for pending connections

ZMQ_LAST_ENDPOINT

Get the last endpoint the socket was connected to

ZMQ_CONNECT_TIMEOUT

Get the connect timeout value

ZMQ_SOCKS_PROXY

Get the SOCKS5 proxy value (string)

ZMQ_CURVE_SERVER

Get whether socket is a curve server (1) or not (0)

ZMQ_CURVE_PRIVATEKEY

Get a the curve socket private key (string)

ZMQ_CURVE_PUBLICKEY

Get a the curve socket public key (string)

ZMQ_CURVE_SERVERKEY

Get a the curve socket public key (string)

ZMQ_PLAIN_SERVER

Get whether socket server will use plain authentication (1) or not (0)

ZMQ_PLAIN_USERNAME

Get the plain socket username (string)

ZMQ_PLAIN_PASSWORD

Get the plain socket password (string)

ZMQ_GSSAPI_SERVER

Get whether socket server will use gssapi authentication (1) or not (0)

ZMQ_GSSAPI_PLAINTEXT

Get whether socket will encrypt gssapi authentication (1) or not (0)

ZMQ_GSSAPI_PRINCIPAL

Get the name of the gssapi principal (string)

ZMQ_GSSAPI_SERVICE_PRINCIPAL

Get the name of the gssapi service principal (string)

ZMQ_MECHANISM

Get the security mechanism (ZMQ_NULL, ZMQ_PLAIN, ZMQ_CURVE, ZMQ_GSSAPI)

Outputs

value - the value set for the option, or [].

See also: zmq_socket, zmq_setsockopt.

4.1.10 zmq_has

: yesno = zmq_has (feature)

Check if the zmq library supports a given feature.

Inputs

feature is the name of feature to check.

Currently known features are:

’ipc’

library supports the ipc:// protocol

’pgm’

library supports the pgm:// protocol

’tipc’

library supports the tipc:// protocol

’norm’

library supports the norm:// protocol

’curve’

library supports the CURVE security mechanism

’gssapi’

library supports the GSSAPI security mechanism

’draft’

library was built with the draft API.

Outputs

yesno - set to true if the feature is available, otherwise false.

4.1.11 zmq_poll

: havedata = zmq_poll (sock, timeout)
: indexlist = zmq_poll (socklist, timeout)

Wait up to timeout time for received data on socket.

Inputs

sock - the socket to wait on.

socklist - the array of sockets to wait on.

timeout - timeout time in milliseconds. A value of 0 will return without waiting. A value of -1 will wait until there is data.

Outputs

havedata - value of 1 if have data.

indexlist - cell array of indexes to sockets that have data.

See also: zmq_socket.

4.1.12 zmq_recv

: data = zmq_recv (sock, len)
: data = zmq_recv (sock, len, flags)

Attempt to receive up to len bytes of data from zeromq socket.

Inputs

sock - the socket to receive from.

len - number of bytes to read.

flags - optional flags to pass to recv

Outputs

data - the read data in an uint8 array.

See also: zmq_socket.

4.1.13 zmq_send

: count = zmq_send (sock, data)
: count = zmq_send (sock, data, flags)

Attempt to send to data bytes of data to zeromq socket.

Inputs

sock - the socket to receive from.

data - data to send - either string or uint8 type.

flags - optional flags to pass to send

Outputs

count - number of bytes written to socket, or -1 on error.

See also: zmq_socket.

4.1.14 zmq_setsockopt

: status = zmq_setsockopt (sock, optionid, value)

Set a socket option on a zeromq socket.

Inputs

sock - the socket to connect.

optionid - the setsockopt option to set.

value - the value to set.

Known valid optionids are:

ZMQ_SUBSCRIBE

Subscribe to incoming messages matching the value. The value is either a string or a uint8 array that must match the start of any incoming message

ZMQ_UNSUBSCRIBE

Unsubscribe from incoming messages

ZMQ_CONNECT_TIMEOUT

Set timeout for connect calls

ZMQ_IDENTITY or ZMQ_ROUTING_ID

Set the identity of a socket (string or uint8 data)

ZMQ_RATE

Set the multicast data rate

ZMQ_PRIORITY

Set the socket priority (linux only)

ZMQ_BACKLOG

Set the queue length for incomming connections

ZMQ_SOCKS_PROXY

Set the socks5 proxy value (string)

ZMQ_CURVE_SERVER

Set whether socket is a curve server (1) or not (0)

ZMQ_CURVE_PRIVATEKEY

Set the curve socket private key (string)

ZMQ_CURVE_PUBLICKEY

Set the curve socket public key (string)

ZMQ_CURVE_SERVERKEY

Set the curve socket public key (string)

ZMQ_PLAIN_SERVER

Set whether socket server will use plain authentication (1) or not (0)

ZMQ_PLAIN_USERNAME

Set the plain socket username (string)

ZMQ_PLAIN_PASSWORD

Set the plain socket password (string)

ZMQ_GSSAPI_SERVER

Set whether socket server will use gssapi authentication (1) or not (0)

ZMQ_GSSAPI_PLAINTEXT

Set whether socket will encrypt gssapi authentication (1) or not (0)

ZMQ_GSSAPI_PRINCIPAL

Set the name of the gssapi principal (string)

ZMQ_GSSAPI_SERVICE_PRINCIPAL

Set the name of the gssapi service principal (string)

Outputs

status - status for setsockopt. On success, setsockopt will return status of true

See also: zmq_getsockopt, ZMQ_SUBSCRIBE, ZMQ_UNSUBSCRIBE, ZMQ_CONNECT_TIMEOUT.

4.1.15 zmq_socket

: sock = zmq_socket (type)

Create a zeromq socket.

Inputs

type - the socket type to create.

Supported socket types are:

ZMQ_PUB

Publish socket

ZMQ_SUB

Subscribe socket

ZMQ_REQ

Request socket

ZMQ_REP

Reply socket

ZMQ_PULL

Pull socket

ZMQ_PUSH

Push socket

ZMQ_PAIR

Pair socket

ZMQ_DEALER

Dealer socket

ZMQ_ROUTER

Router socket

ZMQ_XPUB

Publish socket

ZMQ_XSUB

Subscribe socket

ZMQ_STREAM

Stream socket

Outputs

sock - an instance of octave_zeromq_socket class.

See also: ZMQ_PUB, ZMQ_SUB, ZMQ_PUSH, ZMQ_PULL, ZMQ_REQ, ZMQ_REP, ZMQ_PAIR, ZMQ_DEALER, ZMQ_ROUTER, ZMQ_XPUB, ZMQ_XSUB, ZMQ_STREAM.

4.1.16 zmq_strerror

: errorstr = zmq_strerror ()

Get the last error from zeromq.

Inputs

None

Outputs

errorstr - a string representation of the last error

4.1.17 zmq_unbind

: status = zmq_unbind (sock, endpoint)

Unbind a previously bound zeromq socket from a endpoint.

Inputs

sock - the socket to unbind.

endpoint - the endpoint string to unbind.

Outputs

status - status for unbind. On success, unbind will return a status of true

See also: zmq_socket, zmq_bind .

4.1.18 zmq_version

: [major, minor, patch] = zmq_version ()

Get the ZeroMQ library version.

Inputs

None

Outputs

major, minor patch - version of the ZeroMQ library.

4.1.19 zmq_z85_decode

: data = zmq_z85_decode (instr)

Decode a z85 encoded string to a binary key.

Inputs

instr - a string encoded data

Outputs

data - uint8 decoded data

4.1.20 zmq_z85_encode

: dest = zmq_z85_encode (data)

Encode a binary key as Z85 printable text.

Inputs

data - uint8 data that must have a size divisible by 4.

Outputs

dest - string encoded data


Next: ZeroMQ socket type constants, Up: Function Reference   [Contents][Index]