[ENet-discuss] sending and receiving structs from eNet

Amir Ramezani amir.ramezani1370 at gmail.com
Fri Apr 29 09:52:37 PDT 2016


hello all,
i want to send struct using eNet, the structure definition is like this:
//the structure that represents the game data to be sent
typedef struct gamedata
{
const char *username;
const char *password;
int rank;
bool userpass_incorrect;
bool account_not_exist;
const char *mac_address;
const char *hdd_serial;
const char *ip_address;
int x;
int y;
int z;
int health;
bool is_banned;
bool notify;
const char *pm_user;
const char *chat_user;
const char *message;
const char *server_message;
const char *motd;
bool came_online;
bool went_offline;
}gamedata;

now, when my server receive's this struct from client, it crashe's
size is the size of packet that had been received, and data is the
packet content variable
and gd is the structure that i want to process
i use memcpy to copy from data to struct:
memcpy(gd, data+size, sizeof(*data) +size);
but when i receive it, and want to process it, (dirring the
debugging), i just get a memory access problem
what am i doing wrong?
compiler: gcc 5.3.0
using gnu++14,
ide:code::blocks
debugger: gdb
operating system: windows7 ultimate 32 bit
thanks


More information about the ENet-discuss mailing list