dlunion / zmqcpp-union

Merge libzmq into one cpp file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zmqcpp-union | 中文说明

  • Merge all libzmq source code into one cpp/hpp file

Startup

  • Make zmq_u.cpp and zmq_u.hpp
python make_cpp_hpp.py  # to generate zmq_u.cpp and zmq_u.hpp
  • cpp code
#include "zmq_u.hpp"
#include <string>
#include <iostream>

using namespace std;

int main()
{
	zmq::context_t ctx;
	zmq::socket_t sock(ctx, zmq::socket_type::sub);
	sock.connect("tcp://192.168.27.248:5555");
	sock.set(zmq::sockopt::subscribe, "");

	zmq::message_t message;

	while (true) {
		auto r = sock.recv(message);
		cout << string((char*)message.data(), (char*)message.data() + message.size()) << endl;
	}
	return 0;
}

Reference

About

Merge libzmq into one cpp file

License:MIT License


Languages

Language:C++ 98.2%Language:C 1.7%Language:Python 0.1%Language:Makefile 0.0%