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 <[email protected]> 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 > [email protected] > http://lists.cubik.org/mailman/listinfo/enet-discuss >
_______________________________________________ ENet-discuss mailing list [email protected] http://lists.cubik.org/mailman/listinfo/enet-discuss
