-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.cpp
More file actions
56 lines (43 loc) · 1.08 KB
/
Copy pathmain_test.cpp
File metadata and controls
56 lines (43 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "zmq.hpp"
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <iostream>
#include <string>
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);
}
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());
}
int main(int argc, char *argv[])
{
// if(argc >1){
// start_sub();
// }else{
// start_pub();
// }
SharedKeyValueCli cli;
cli.init("tcp://127.0.0.1");
std::string k,v;
k = "tmp";
int num = 0;
while(num++<10){
try{
k= "key" + std::to_string(num);
v = "value"+std::to_string(num);
cli.set(k,v);
}catch(std::exception &e){
std::cout << e.what() << std::endl;
}
}
std::this_thread::sleep_for(std::chrono::minutes(60));
return 1;
}