Original Post
Forgive me if this is an utterly newbie question: What''s the best way to handle variable packet size receipt in WinSock?
A previous post in another thread indicated that you could peek at the packet being received, and decide what to do based on it; is this a good way to handle variable sized packets?
By variable sized, I mean the following:
typedef struct _Velocity
{
DWORD dwType;
DWORD dwSize;
float X;
float Y;
float Z;
} Velocity;
typedef struct _TextMessage
{
DWORD dwSize;
DWORD dwType;
char szMessage[128];
DWORD dwColor;
}
Obviously I don''t want to pad each structure with extra bytes so that I can handle each packet the "easy way"... what about sending a ''type packet'' to the server that indicates the next received packet''s type will be?
MatrixCubed