Wow Osaou, overkill.
For a simple solution:
Another solution, functionally equivalent to Osaou's:
__int32 size, handle;
recv(socket, (void*)&size, sizeof(size),0);
recv(socket, (void*)&handle, sizeof(handle),0);
This may look more complex than the first example, but once error checking is put in (i.e. if you don't receive the entire header in one go), the second actually becomes more elegant.
unsigned char buffer;
recv(socket, (void*)buffer, sizeof(buffer),0);
__int32 size = *(__int32*)buffer; //Or __int32& size
__int32 handle = *(__int32*)(buffer + 4); //Or __int32& handle
Disclaimer about the following: Not 100% sure.
Due to the nature of compiler optimizations and structure padding, Osaou's solution may be compromised by stray padding bits in the structure, thrown in by the compiler. This is (at least partially) why I didn't use a 'union' approach.
I actually typed up a much more informative post, but cboard decided to eat it so I'm too lazy to go into the same detail now.
OK wtf, cboard just vomited my other post back up. Whatever.