One word: Serialization.<br><br><a href="http://en.wikipedia.org/wiki/Serialization">http://en.wikipedia.org/wiki/Serialization</a><br><br><div class="gmail_quote">On Thu, Apr 2, 2009 at 10:06 PM, ismael <span dir="ltr"><<a href="mailto:ismael.bamba@laposte.net">ismael.bamba@laposte.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5"><br>
Daniel Aquino wrote:<br>
> I currently have something similar too:<br>
><br>
> struct packet {<br>
> enum packet_type type;<br>
> void* data;<br>
> } packet;<br>
><br>
> I assign this to the ENetPacket->data but as you all probably know the<br>
> (void*) pointer address is sent in the packet and not the data that<br>
> the pointer reflects...<br>
><br>
> I need a method to send the "type" and different types of data...<br>
><br>
> In one instance data might reflect a char* or could be an ENetAddress etc...<br>
><br>
> Any advice on how I should be approaching this?<br>
><br>
> Thanks!<br>
> _______________________________________________<br>
> ENet-discuss mailing list<br>
> <a href="mailto:ENet-discuss@cubik.org">ENet-discuss@cubik.org</a><br>
> <a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" target="_blank">http://lists.cubik.org/mailman/listinfo/enet-discuss</a><br>
><br>
><br>
><br>
</div></div>Hi there,<br>
<br>
You are lacking one important information: the data length, that is<br>
<div class="im"><br>
struct packet {<br>
enum packet_type type;<br>
</div> unsigned len;<br>
void* data;<br>
} packet;<br>
<br>
or if you would prefer:<br>
<br>
struct packet_header {<br>
enum packet_type type;<br>
unsigned len;<br>
}packet_header;<br>
<br>
<br>
struct packet {<br>
packet_header hdr;<br>
void* data;<br>
} packet;<br>
<br>
<br>
<br>
<br>
Hope it helps!<br>
<div><div></div><div class="h5"><br>
<br>
<br>
_______________________________________________<br>
ENet-discuss mailing list<br>
<a href="mailto:ENet-discuss@cubik.org">ENet-discuss@cubik.org</a><br>
<a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" target="_blank">http://lists.cubik.org/mailman/listinfo/enet-discuss</a><br>
</div></div></blockquote></div><br>