I want to send structures in a Windows socket. I use TCP protocol.
For example I have this structure :
typedef struct  headerLobby
{
    unsigned      nbGames;
}    head; 
I send my structure :
char buff[DEFAULT_BUFFER_LENGTH]; //DEFAULT_BUFFER_LENGTH = 512
headerLobby header;
header.nbGames = 1;
memcpy(buff, &header,  sizeof(headerLobby));
send(ClientSocket, buff, sizeof(headerLobby, 0);
I receive the data :
headerLobby header;
char recvbuf[DEFAULT_BUFFER_LENGTH];
memset(recvbuf, 0, DEFAULT_BUFFER_LENGTH);
int iResult = recv(ConnectSocket, recvbuf, DEFAULT_BUFFER_LENGTH, 0);
memcpy(&header,recvbuf,  sizeof(headerLobby));
But when I print header.nbrGames I haven't the good value.
The client and the server are both in windows 8 64bits and the processor intel x64. I don't understand what's wrong in my code.
 
     
     
     
    