Probably you forgot to specify the bit size for
msg_size
, and that may put data alignment if effect. Please check up.
One more thing:
short
and
long
are among so called "fundamental types"; their actual size depends on platform:
https://msdn.microsoft.com/en-us/library/cc953fe1.aspx[
^].
So, I would avoid using such types in the situations where you need exact bit size. For such purposes, C++11 (I do understand, this is not about VS 6.0) defines the following:
http://en.cppreference.com/w/cpp/types/integer[
^].
If you don't have C++11, you can use, for example, platform-specific definitions, such as Windows WORD, etc.
By the way, if you suspect some version of C++ coming with some version of Visual Studio does something wrong, you can always compare it with VS 2013 or VS 2015, Community Edition, which come free of charge.
—SA