client :
struct packet
{
uint32_t id;
uint32_t x;
uint32_t y;
};
void send()
{
packet p;
p.id=1;
p.x=10;
p.y=10;
send( m_Socket, (const char*)&p, sizeof(p), 0);
}
server:
unsigned int extractUnsignedInt(char** msg)
{
unsigned int* value;
value = (unsigned int*) *msg;
*msg += sizeof(unsigned int);
return *value;
}
void recieve()
{
char *buf;
recv(pClientContext->GetSocket(), buf, sizeof(buf), 0);
unsigned int id = extractUnsignedInt(&buf);
unsigned int x = extractUnsignedInt(&buf);
unsigned int y = extractUnsignedInt(&buf);
}
Is this correct ? because the server outputs incorrect values.