C++ serialization:
int main ()
{
GOOGLE_PROTOBUF_VERIFY_VERSION;
proto::Request request;
std::string output;
request.set_fieldone("X");
request.set_fieldtwo("Y");
// Prepare our context and socket
zmq::context_t context (1);
zmq::socket_t socket (context, ZMQ_REQ);
socket.connect ("tcp://localhost:5555");
request.SerializeToString(&output);
long size = output.length();
zmq::message_t request(size);
memcpy(request.data(), &output, size);
socket.send(request);
return 0;
}
Python de-serialization:
def __init__(self):
self.database.connect()
self.context = zmq.Context()
self.socket = self.context.socket(zmq.REP)
self.socket.bind("tcp://*:5555")
self.request = call_init_pb2.DialRequest()
def run(self):
message = self.socket.recv()
self.request.ParseFromString(message)
Which gives me the error message:
self.request.ParseFromString(message)
google.protobuf.message.DecodeError: Error parsing message
What I would like to achieve is to serialize the message in C++, send it over a network to a Python server. De-serialize the message, and then perform some business logic on the server side to check for certain properties of the message. I can send the string, and its received with the same length and type at the Python server side, but the parsing doesn't work.
Did I miss some fundamental basic knowledge?