Created
November 30, 2011 14:39
-
-
Save skayred/1409283 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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