Last active
August 29, 2015 14:02
-
-
Save easytiger/f7316f2c7700f9a6a424 to your computer and use it in GitHub Desktop.
This file contains 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
#include <assert.h> | |
#include <stdio.h> | |
#include <nanomsg/nn.h> | |
#include <nanomsg/pubsub.h> | |
#include <iostream> | |
#include <sstream> | |
#include <assert.h> | |
#include <stdint.h> | |
#include <zmq.h> | |
#include <time.h> | |
#include <ostream> | |
#include <cstdlib> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <string.h> | |
using namespace std; | |
int main (const int argc, const char **argv) | |
{ | |
int sock = nn_socket (AF_SP, NN_SUB); | |
assert (sock >= 0); | |
if (argc < 2) | |
{ | |
cout << "-USAGE: " << argv[0] << "<uint log print modulo>" << endl; | |
abort(); | |
} | |
assert (nn_setsockopt (sock, NN_SUB, NN_SUB_SUBSCRIBE, "", 0) >= 0); | |
assert (nn_connect (sock, "tcp://localhost:5563") >= 0); | |
uint64_t c = 1; | |
while (1) | |
{ | |
char *buf = NULL; | |
int bytes = nn_recv(sock, buf, NN_MSG, 0); | |
if (c % atoi(argv[2]) == 0) | |
{ | |
cout << "FOO: bytes=" << bytes << endl ; | |
//cout << "RECV " << buf << " with rc="<< bytes << endl; | |
} | |
++c; | |
nn_freemsg (buf); | |
} | |
nn_shutdown (sock, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment