Zeromq Toolkit - zeromq


Package: zeromq

The zeromq package provides GNU Octave bindings to the ZeroMQ library to provide fast distributed messaging options using IPC, TCP, TIPC and multi-casting.

The usage is very close to the ZeroMQ library C language bindings for the socket creation and manipulation with the exception of creating a zeromq context, which is automatically done in the bindings internals.

For example, a basic client that does a request / reply from a server on port local port 5555 (available as zmq_example1.m):

 
 %% Create socket and connect to server
 requester = zmq_socket (ZMQ_REQ);
 zmq_connect (requester, "tcp://localhost:5555");
 
 %% send some data
 zmq_send (requester, uint8("Hello"), 5, 0); 
 %% try to read up to 10 bytes of reply data.
 received = zmq_recv (requester, 10, 0);
 
 zmq_close (requester);
 

Implemented functions are:

zmq_bind

Bind a zeromq socket to an endpoint.

zmq_close

Close a zeromq socket.

zmq_connect

Connect a zeromq socket to an endpoint

zmq_disconnect

Disconnect a zeromq socket from an endpoint

zmq_errno

Get system errno value.

zmq_getsockopt

Get current value of a zeromq socket option.

zmq_has

Check zmq for a given feature.

zmq_poll

Poll a socket or sockets for a timeout or incoming data available.

zmq_recv

Attempt to read data from a zeromq socket.

zmq_send

Attempt to send data from a zeromq socket.

zmq_setsockopt

Set a zeromq socket option.

zmq_strerror

Get the last zmq error string.

zmq_unbind

Unbind a previously bound zeromq socket.

zmq_version

Get the zeromq library version numbers.

Implemented functions depending on version of libzmq are:

zmq_curve_keypair

Generate a random private/public keypair.

zmq_curve_public

Derive the public key from a private key.

zmq_z85_decode

decode a z85 encoded string to a binary key.

zmq_z85_encode

encode a binary key as Z85 printable text.

In addition, a iszmq function is provided to verify whether a object is a zeromq socket

Example code files for zeromq usage:

zmq_example1

Simple client REQ socket example that attempts to connect to a server and send a hello command and get back the response.

zmq_example2

Simple server REP socket example that creates the server that the client from example 1 will connect to and responds back to client ’requests’

zmq_example3

Simple server PUB socket example that creates ’weather’ server sends weather updates for random zip codes.

zmq_example4

Simple client SUB socket example that creates client that connects to the ’weather’ server and subscribes for weather updates from zip-code 10001.

zmq_example5

Simple client STREAM socket example that creates client that connects to octave.org and posts HEAD request.

View example code using edit examples/example_name

ie:

 edit examples/zmq_example1
 

See also: http://zeromq.org, examples/zmq_example1.m, examples/zmq_example2.m, examples/zmq_example3.m, examples/zmq_example4.m, examples/zmq_example5.m.