File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// Copyright (c) 2020 by Chrono
22
3- #ifndef _SPIN_LOCK_HPP
4- #define _SPIN_LOCK_HPP
3+ #ifndef _ZMQ_HPP
4+ #define _ZMQ_HPP
55
66#include " cpplang.hpp"
77
8+ // /usr/include/zmq.hpp
89#include < zmq.hpp>
910
1011BEGIN_NAMESPACE (cpp_study)
@@ -30,19 +31,26 @@ class ZmqContext final
3031 return ctx;
3132 }
3233public:
33- zmq_socket_type socket ( int mode, size_t hwm = 1000 ) const
34+ zmq_socket_type recv_sock ( size_t hwm = 1000 ) const
3435 {
35- zmq_socket_type sock (context (), mode );
36+ zmq_socket_type sock (context (), ZMQ_PULL );
3637
37- sock.setsockopt (
38- mode == ZMQ_PULL ? ZMQ_RCVHWM : ZMQ_SNDHWM,
39- hwm);
38+ sock.setsockopt (ZMQ_RCVHWM, hwm);
39+
40+ return sock;
41+ }
42+
43+ zmq_socket_type send_sock (size_t hwm = 1000 ) const
44+ {
45+ zmq_socket_type sock (context (), ZMQ_PUSH);
46+
47+ sock.setsockopt (ZMQ_SNDHWM, hwm);
4048
4149 return sock;
4250 }
4351};
4452
4553END_NAMESPACE (cpp_study)
4654
47- #endif // _SPIN_LOCK_HPP
55+ #endif // _ZMQ_HPP
4856
Original file line number Diff line number Diff line change 11-- copyright (c) 2020 chrono
22
3- -- it is more flexible than json
3+ -- lua is more flexible than json
4+
45config = {
56
67 max_buf_size = 4 * 1024 ,
78
9+ zmq_ipc_addr = " tcp://127.0.0.1:5555" ,
10+
11+ http_addr = " http://localhost/cpp_study?token=cpp@2020" ,
12+
813 keyword = " super" ,
914
1015 sold_criteria = 100 ,
You can’t perform that action at this time.
0 commit comments