[zeromq-dev] Communication between C++ zmq client and Python zmq Server

Thomas Rodgers rodgert at twrodgers.com
Sat Feb 3 00:54:36 CET 2018


<<I think this got dropped because of the size of the included replies>>

Is this correct?


Yes


> 1. What advantages do I have when using something like protocol buffer to
> serialization data instead of
> send the data of a basic way such as I perform here turn the data to
> string and sending it?
>

If you want to send complex data structures, portably between different
programming language environments and processor architectures.
This is not a goal of ZeroMQ and is explicitly left to other libraries and
tools.

| 2.  Why use memcpy is bad or not suited?

http://en.cppreference.com/w/cpp/algorithm/copy
http://en.cppreference.com/w/cpp/algorithm/copy_n

are better alternatives in C++ and as, or more efficient than ::memcpy
(they in fact delegate, as inline code to ::memcpy if that is the fastest
way to perform the copy).

your example would read -

#include <algorithm>

...

std::copy_n(result.c_str(), result.size() + 1, request.data());

OR

std::copy(result.begin(), result.size(), request.data());

On Wed, Jan 31, 2018 at 12:33 PM, Bernardo Augusto García Loaiza <
botibagl at gmail.com> wrote:

> Hi Thomas, thanks for your appreciations
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180202/13d41b79/attachment.htm>


More information about the zeromq-dev mailing list