Skip to content

Instantly share code, notes, and snippets.

@skayred
Created November 30, 2011 14:39
Show Gist options
  • Select an option

  • Save skayred/1409283 to your computer and use it in GitHub Desktop.

Select an option

Save skayred/1409283 to your computer and use it in GitHub Desktop.
#ifndef ZHELPERS_HPP
#define ZHELPERS_HPP
#include <iostream>
#include <zmq.hpp>
#define within(num) (int) ((float) (num) * random () / (RAND_MAX + 1.0))
static std::string s_recv(zmq::socket_t & socket) {
zmq::message_t message;
socket.recv(&message);
return std::string(static_cast<char*>(message.data()), message.size());
}
static bool s_send(zmq::socket_t & socket, const std::string & string) {
zmq::message_t message(string.size());
memcpy(message.data(), string.data(), string.size());
bool rc = socket.send(message);
return (rc);
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment