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:
Bind a zeromq socket to an endpoint.
Close a zeromq socket.
Connect a zeromq socket to an endpoint
Disconnect a zeromq socket from an endpoint
Get system errno value.
Get current value of a zeromq socket option.
Check zmq for a given feature.
Poll a socket or sockets for a timeout or incoming data available.
Attempt to read data from a zeromq socket.
Attempt to send data from a zeromq socket.
Set a zeromq socket option.
Get the last zmq error string.
Unbind a previously bound zeromq socket.
Get the zeromq library version numbers.
Implemented functions depending on version of libzmq are:
Generate a random private/public keypair.
Derive the public key from a private key.
decode a z85 encoded string to a binary key.
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:
Simple client REQ socket example that attempts to connect to a server and send a hello command and get back the response.
Simple server REP socket example that creates the server that the client from example 1 will connect to and responds back to client ’requests’
Simple server PUB socket example that creates ’weather’ server sends weather updates for random zip codes.
Simple client SUB socket example that creates client that connects to the ’weather’ server and subscribes for weather updates from zip-code 10001.
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.
Package: zeromq