[ENet-discuss] Sending a struct which contains a pointer to arbitrary data...

Nuno Silva little.coding.fox at gmail.com
Thu Apr 2 14:42:29 PDT 2009


One word: Serialization.

http://en.wikipedia.org/wiki/Serialization

On Thu, Apr 2, 2009 at 10:06 PM, ismael <ismael.bamba at laposte.net> wrote:

>
> Daniel Aquino wrote:
> > I currently have something similar too:
> >
> > struct packet {
> >        enum packet_type type;
> >        void* data;
> > } packet;
> >
> > I assign this to the ENetPacket->data but as you all probably know the
> > (void*) pointer address is sent in the packet and not the data that
> > the pointer reflects...
> >
> > I need a method to send the "type" and different types of data...
> >
> > In one instance data might reflect a char* or could be an ENetAddress
> etc...
> >
> > Any advice on how I should be approaching this?
> >
> > Thanks!
> > _______________________________________________
> > ENet-discuss mailing list
> > ENet-discuss at cubik.org
> > http://lists.cubik.org/mailman/listinfo/enet-discuss
> >
> >
> >
> Hi there,
>
> You are lacking one important information: the data length, that is
>
> struct packet {
>       enum packet_type type;
>         unsigned len;
>       void* data;
> } packet;
>
> or if you would prefer:
>
> struct packet_header {
>       enum packet_type type;
>        unsigned len;
> }packet_header;
>
>
> struct packet {
>  packet_header hdr;
>  void* data;
> } packet;
>
>
>
>
> Hope it helps!
>
>
>
> _______________________________________________
> 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/20090402/c8466982/attachment.htm>


More information about the ENet-discuss mailing list