wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable.tar.gz --no-check-certificate tar -zxvf libsodium-1.0.18-stable.tar.gz cd libsodium-stable/ ./configure make make check sudo make install sudo ldconfig
安装libzmq
1 2 3 4 5 6
wget https://github.com/zeromq/libzmq/releases/download/v4.3.4/zeromq-4.3.4.tar.gz tar -zxvf zeromq-4.3.4.tar.gz cd zeromq-4.3.4 ./configure --with-libsodium=/usr/local make sudo make install
安装zmqpp
1 2 3 4
git clone https://github.com/zeromq/zmqpp.git cd zmqpp make sudo make install
// initialize the 0MQ context zmqpp::context context;
// generate a pull socket zmqpp::socket_type type = zmqpp::socket_type::reply; zmqpp::socket socket(context, type);
// bind to the socket socket.bind(endpoint); while (1) { // receive the message zmqpp::message message; // decompose the message socket.receive(message); string text; message >> text;
// initialize the 0MQ context zmqpp::context context;
// generate a push socket zmqpp::socket_type type = zmqpp::socket_type::req; zmqpp::socket socket(context, type);
// open the connection cout << "Connecting to hello world server…" << endl; socket.connect(endpoint); int request_nbr; for (request_nbr = 0; request_nbr != 10; request_nbr++) { // send a message cout << "Sending Hello " << request_nbr <<"…" << endl; zmqpp::message message; // compose a message from a string and a number message << "Hello"; socket.send(message); string buffer; socket.receive(buffer); cout << "Received World " << request_nbr << endl; } }
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.5/protobuf-cpp-3.21.5.tar.gz tar -zxvf protobuf-cpp-3.21.5.tar.gz cd protobuf-3.21.5/ ./configure -prefix=/usr/local/ make sudo make install