[ENet-discuss] sending struct data

Nuno Silva little.coding.fox at gmail.com
Sun Jan 25 23:46:42 PST 2009


The name may somehow be missing it's terminator ('\0'), check if you're
correctly sending it and if you even received it in the first place.

On Mon, Jan 26, 2009 at 1:28 AM, Andrew Fenn <andrewfenn at gmail.com> wrote:

> I've been reading through any information related to enet on if this
> is possible and have decided to give up and ask on the mailing list.
>
> typedef struct {
>    char name[40];       /* Players name */
>    enet_uint32 conState;  /* Connection state */
> } Player;
>
> I have the following server side code..
>
> // enet event, data, data size, channel, priority
> message(mEvent.peer,&player,sizeof(player),0,ENET_PACKET_FLAG_RELIABLE);
>
> I have the following client side code..
>
> Player player;
> memcpy(&player, event.packet->data, sizeof(Player));
> printf("Packet contains name: \"%s\" connection state: 0x%08x was
> inside.\n", player.name, player.conState);
>
> When sending and receiving the size is the same (44 bytes), however
> when the data arrives player.name has garbage around the data.
> (player.conState is fine).
>
> My question is, what is the correct way of doing this?
>
> Regards,
> Andrew
> _______________________________________________
> 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/20090126/296744e8/attachment.htm>


More information about the ENet-discuss mailing list