Hey. I want to make a packet structure, something like
struct Packet {
int cmd; /* command */
int len; /* length of body */
char body[30]; /* body (should be length of len though, might use std::string) */
};
Now, if I recieve some data thru a socket (I'm using some socket class based on Winsock2 and for the client SDL_net) read data (command, length & body) into a Packet structure?
Basically I'm wanting the socket stream to look like cmd len body
for example 0x01 0x05 hello
, but I don't know how I'd parse that into a Packet structure.