[ENet-discuss] protobuf woes and serializing to string and creating a packet out of it

Shaun Reich predator106 at gmail.com
Mon Feb 11 17:23:00 PST 2013


I'm using protobuf to send packets, I can serialize and deserialize them
just fine in the code I link below, even if I set one of the members to 0
(e.g. set_versionminor(0). It works fine if I serialize the contents, then
do ss2 << ss.str(); to put that data into another buffer which i then
deserialize..

I did that just for testing, and it works fine.

However, as soon as I put the contents in an ENetPacket, with ENetPacket
*packet = enet_packet_create(ss.str().c_str(), ss.str().size(),
ENET_PACKET_FLAG_RELIABLE);

and     std::stringstream ss2; ss2 << (packet->data);

it breaks if one of those set_.. members are set to 0. I belief this has
something to do with \0 the NUL terminator..but I'm not sure what's going
on.

All I know is that it works until I make a packet out of it, at which point
if the data i serialized had a 0 in it, my deserialization breaks down
entirely.

Maybe it has something to do with the fact that packet->data is an
enet_uint8?

code below, I omitted my de/serializer because it doesn't seem to be the
issue, but how i actually store it in the packet and retrieve it.

http://paste.kde.org/669368/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20130211/c6470411/attachment.html>


More information about the ENet-discuss mailing list