[zeromq-dev] ZeroMQ C++
Michal Vyskocil
michal.vyskocil at gmail.com
Fri Jul 26 13:09:52 CEST 2019
Hi SIMON,
unfortunately I have never used libzmq (except for toy examples). I can
only recommend you to add czmq (https://github.com/zeromq/czmq/) and
zpoller (https://github.com/zeromq/czmq/blob/master/src/zpoller.c). As the
library is based on top of libzmq, you can pass zmq sockets to zpoller_add (
https://github.com/zeromq/czmq/blob/master/src/zpoller.c#L141) or any other
function accepting sockets. The advantage is that you will get MUCH easier
API than zmq has.
Bye
Michal
On Thu, Jul 25, 2019 at 10:26 PM SIMON BABY <simonkbaby at gmail.com> wrote:
> Thank you Michal. While building my code, I see below error. can anyone
> suggest to fix this.
>
> tdy at ubuntu:~/ZIPCpp$ make all
> mkdir -p build/src/fmt/
> g++ -O2 -std=c++11 -fPIC -Wall -Wextra -fmessage-length=0 -pthread
> -I/cppzmq/ -Iinclude -MMD -MP -c src/fmt/posix.cc -o
> build/src/fmt/posix.cc.o
> mkdir -p build/src/fmt/
> g++ -O2 -std=c++11 -fPIC -Wall -Wextra -fmessage-length=0 -pthread
> -I/cppzmq/ -Iinclude -MMD -MP -c src/fmt/format.cc -o
> build/src/fmt/format.cc.o
> mkdir -p build/src/
> g++ -O2 -std=c++11 -fPIC -Wall -Wextra -fmessage-length=0 -pthread
> -I/cppzmq/ -Iinclude -MMD -MP -c src/zipc.cpp -o build/src/zipc.cpp.o
> src/zipc.cpp: In function ‘bool zipc::sockPoll(zmq::socket_t*, int)’:
> src/zipc.cpp:115:53: error: cannot convert ‘zmq::socket_t’ to ‘void*’ in
> initialization
> pollitem_t pollItem = { *sock, 0, ZMQ_POLLIN, 0 };
> ^
> src/zipc.cpp: In static member function ‘static std::vector<unsigned int>
> zipc::Endpoint::pollEndpoints(const EndpointList&, int)’:
> s*rc/zipc.cpp:365:69: error: cannot convert ‘zmq::socket_t’ to ‘void*’ in
> initialization*
> pollitem_t pollItem = { *epIt->get().sock, 0, ZMQ_POLLIN, 0 };
> // no constructor for pollitem_t
> ^
> src/zipc.cpp: In member function ‘void zipc::Proxy::run()’:
> *src/zipc.cpp:545:78: error: cannot convert ‘zmq::socket_t’ to ‘void*’ for
> argument ‘1’ to ‘void zmq::proxy_steerable(void*, void*, void*, void*)’*
> proxy_steerable(*this->feSock, *this->beSock, nullptr,
> *this->ctlPullSock);
>
> ^
> src/zipc.cpp: At global scope:
> src/zipc.cpp:58:6: warning: ‘void zipc::mpmsgListSend(zipc::MPMsgList&,
> zmq::socket_t*, int)’ defined but not used [-Wunused-function]
> void mpmsgListSend(MPMsgList &mpmsgList, socket_t *sock, int flags)
> ^
> src/zipc.cpp:70:6: warning: ‘bool zipc::msgRecvPoll(zipc::Msg&,
> zmq::socket_t*, int)’ defined but not used [-Wunused-function]
> bool msgRecvPoll(Msg &msg, socket_t *sock, int timeoutMs)
> ^
> src/zipc.cpp:129:6: warning: ‘void zipc::sockDetach(zmq::socket_t*, const
> string&, zipc::AttachType)’ defined but not used [-Wunused-function]
> void sockDetach(socket_t *sock, const std::string &epAddr, AttachType
> attachType)
> ^
> Makefile:50: recipe for target 'build/src/zipc.cpp.o' failed
> make: *** [build/src/zipc.cpp.o] Error 1
> tdy at ubuntu:~/ZIPCpp$ uname -a
> Linux ubuntu 4.10.0-28-generic #32~16.04.2-Ubuntu SMP Thu Jul 20 10:19:13
> UTC 2017 i686 i686 i686 GNU/Linux
>
>
> Rgds
> Simon
>
> On Thu, Jul 25, 2019 at 1:06 PM Michal Vyskocil <michal.vyskocil at gmail.com>
> wrote:
>
>> Hi,
>>
>> Just use zpoller from czmq. It is C library, but with really nice API you
>> can call from C++ code
>>
>> Dne čt 25. 7. 2019 19:33 uživatel Brett Viren via zeromq-dev <
>> zeromq-dev at lists.zeromq.org> napsal:
>>
>>> SIMON BABY <simonkbaby at gmail.com> writes:
>>>
>>> > I am looking for a sample source code in c++ with multiple end-points
>>> defined in the same process.
>>> > Basically my process has to send a receive messages to/from other
>>> processes.
>>>
>>> These two requirements seem contradictory to me.
>>>
>>> In any case, the zmqpp package has tests written in C++ that have
>>> multiple sockets in the same process.
>>>
>>>
>>> https://github.com/zeromq/zmqpp/blob/develop/src/tests/test_socket.cpp#L84
>>>
>>> I happen to develop in C++ and use libczmq. Although it is a C library,
>>> there has been nothing that limits me using it with C++.
>>>
>>> -Brett.
>>>
>>> _______________________________________________
>>> zeromq-dev mailing list
>>> zeromq-dev at lists.zeromq.org
>>> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>
>>
--
best regards
Michal Vyskocil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20190726/0c042dee/attachment.htm>
More information about the zeromq-dev
mailing list