[ENet-discuss] Packet Data query

Pablo de Heras Ciechomski pablo.deheras at gmail.com
Fri Dec 19 07:08:30 PST 2014


Hi Ian,

To me it seems this is a serialisation problem that is

sizeof(MyStructure) =/= size of data written into the ENet packet?

I can assure you that I have yet to have seen that writing 4 bytes into a
packet data block has arrived as 8 or other. Bytes in == bytes out.

What I would consider instead is writing the data one by one (using your
own integer/float/string serialisation routines) and maybe using pragma
pack 1 for your structures, making sure that the structure is not
byte-padded by the compiler for performance memory access reasons?

I hope I have understood your question properly.

Best regards,

Pablo

On Thu, Dec 18, 2014 at 6:59 PM, Ian Wiles <
ian.alexander.wiles at googlemail.com> wrote:
>
> Hi,
>
> I've started using enet recently, using the pre-built libs for VC++. I'm
> trying to pack an object that is designed for transport over the wire, but
> after comparing the object with enet's packet->data the object, which is 4
> bytes, grows by 4 bytes. Is there a minimum size for packet creation? I can
> apply a bit mask for now but it's not scalable since any additional data
> will change. I had no trouble sending a struct over so maybe I need to
> serialize the objects properly. Any advice would be good,
>
> Cheers,
> Ian
>
> _______________________________________________
> ENet-discuss mailing list
> ENet-discuss at cubik.org
> http://lists.cubik.org/mailman/listinfo/enet-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20141219/72dc505a/attachment.html>


More information about the ENet-discuss mailing list