How to install ZeroMQ on Ubuntu
Posted on June 16, 2015 • 1 minutes • 177 words
Before installing, make sure you have installed all the needed packages
sudo apt-get install libtool pkg-config build-essential autoconf automake
sudo apt-get install libzmq-dev
Install libsodium
git clone git://github.com/jedisct1/libsodium.git
cd libsodium
./autogen.sh
./configure && make check
sudo make install
sudo ldconfig
Install zeromq
# latest version as of this post is 4.1.2
wget http://download.zeromq.org/zeromq-4.1.2.tar.gz
tar -xvf zeromq-4.1.2.tar.gz
cd zeromq-4.1.2
./autogen.sh
./configure && make check
sudo make install
sudo ldconfig
Verify to see if zeromq installed correctly
I’m familiar with Node.js so I’m going to use the Node.js hwserver
example
from zeromq’s website. If you see “Listening on 5555…”, you’re good to go.
// Hello World server
// Binds REP socket to tcp://*:5555
// Expects "Hello" from client, replies with "world"
var zmq = require('zmq');
// socket to talk to clients
var responder = zmq.socket('rep');
responder.on('message', function(request) {
console.log("Received request: [", request.toString(), "]");
// do some 'work'
setTimeout(function() {
// send reply back to client.
responder.send("World");
}, 1000);
});
responder.bind('tcp://*:5555', function(err) {
if (err) {
console.log(err);
} else {
console.log("Listening on 5555…");
}
});
process.on('SIGINT', function() {
responder.close();
});