Not so much a problem but more of an coding execution standpoint.
I am in the middle of programming a game server using C++ & Winsock. All good so far. 8)
I am making a network class & I have the app at the stage now where the client will accept and disconnect multiple clients gracefully and bug free (as far as I can tell).
I am now stuck on how I shoud handle the recieve code.
The incoming data will be of a variable size with the first byte (or two) being the identifier of the incoming packet type.
[Byte1 (Idenifier][Byte2... ByteN (Data)] // Data length will be constant depending on what the identifier is.
The problem is where I should handle the recieved data. If I was going to have the class reconstuct the incoming data and check for packet boundaries, the class would have to know about all of the data types, which would then decrease re-usablility (as the class would then be 'custom written' for the application.
However, if I get the class to just fill a 'client buffer' for each incoming socket connection, I could get the application to reconstruct the data (and not the class). But, then this semi-defeats the purpose of having the network class.
Any ideas on how I can get the class to handle the incoming data better?
Thanks in advance.