[zeromq-dev] epgm / pgm / auto discovery in C++ on Windows and VS2013
Bob Clarke
optionguy71 at gmail.com
Thu Nov 27 17:58:34 CET 2014
James - regarding your message setup:
std::string szMessageData = "Foo";
zmq::message_t zmqMsgOut(sizeof(szMessageData) + 1);
memcpy((void *)zmqMsgOut.data(), szMessageData.c_str(),
sizeof(szMessageData));
1) why the "+1" at the end of the zmqMsgOut setup? Messages are not null
terminated (though you can make them that way).
2) the zmqMsgOut size parameter should be the length of the string, which
is not sizeof(szMessageData). Use szMessageData.length().
3) for the memcpy() line, you are using sizeof() on the string, which is
not the same as the string length, which is what you want.
Try this: memcpy((void*)zmqMsgOut.data(), szMessageData.data(),
szMessageData,length() );
Bob
On Thu, Nov 27, 2014 at 7:06 AM, James Chapman <james at linux-101.org> wrote:
> Thanks again Jarek
>
> If I wrap the bind in a try catch I get the following error message:
>
> "Protocol not supported"
>
> I get the same exception thrown on the subscriber whilst trying to
> perform the connect().
>
> This therefore probably has something to do with the ZMQ build on my
> platform. Do I need to pass any parameters or flags at compile time to
> have ZMQ support the protocol? Do I need to change any Windows OS
> settings to support this?
>
> FWIW, I've put the VS project here:
> https://github.com/JimmyReload/zeromq-snippets
>
> Thanks
> James
>
>
> On 27 November 2014 at 13:24, Dorvin <dorvin at tlen.pl> wrote:
> > W dniu 2014-11-27 11:31, James Chapman pisze:
> >> I looked at the following example from the user guide:
> >> http://zguide.zeromq.org/cpp:wuproxy and tried to implement a similar
> >> example. Obviously I'm still doing something wrong because I get
> >> exceptions thrown when trying to bind on the publisher and an
> >> exception thrown when trying to connect on the subscriber.
> > I tried to run epgm with pre-c++11 and 0MQ 4.0.4 and it didn't throw any
> > exception. Try to provide address explicitly and not with c_str.
> >
> > I wasn't able to make it pass messages, though. I haven't used pgm/epgm
> > on windows so you'll probably have to wait for response from someone
> > more experienced in this area.
> >
> >>
> >> If I change from epgm to tcp (see publishAddress / subscribeAddress
> >> string) then the publisher sucessfully sends messages, but the
> >> subscriber doesn't receives them.
> > You have port misconfiguration. Then you will spot classical issue of
> > slow joiners. ZeroMQ works asynchronously and fact that connect call
> > succeeded doesn't mean underlying sockets are ready. Add Sleep(1000)
> > after connect or make recv call non-blocking and it should work better.
> >
> >
> > Jarek
> >
> > _______________________________________________
> > zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20141127/0e5a16bf/attachment.htm>
More information about the zeromq-dev
mailing list