Original Post
INPACKET:
struct INPACKET {
__int32 SID; // Session ID
__int16 UID; // User ID
__int16 AID; // Action ID
__int16 TID; // Type ID
void *Param; // Parameter
};
Client side:
bool CNetwork::SendInPacket(INPACKET *pck)
{
CClientSock sck;
pck->AID = htonl(pck->AID);
pck->UID = htonl(pck->UID);
pck->SID = htonl(pck->SID);
pck->TID = htonl(pck->TID);
sck.Init("127.0.0.1", 1985); // host, port
sck.Send((char *)&pck, sizeof(INPACKET));
sck.Shutdown();
return true;
}
Server side:
if (sockret = Sock.Receive(buffer, 512))
{
INPACKET *pack;
pack = (INPACKET *)&buffer
cout << "pack->AID: " << pack->AID << "\n";
cout << "pack->UID: " << pack->UID << "\n";
cout << "pack->SID: " << pack->SID << "\n";
cout << "pack->TID: " << pack->TID << "\n";
cout << "pack->Param: " << pack->Param << "\n";
}
Sent values by client:
pack.AID: 1
pack.UID: 2
pack.SID: 3
pack.TID: 4
pack.Param: 00000000
Resulting output of server:
pack->AID: 30712
pack->UID: 8021
pack->SID: 1244860
pack->TID: 10816
pack->Param: 7FFDF000
Question:
What am I doing wrong?