04-03-2009, 01:58 AM
There are two headers I'm using. The packet length and the packet id(playerhp, attacknpc, etc(enum)). So a valid packet would be(IN DEC):
5 2 3 'h' 'i' '!'
That can be interpreted as a packet with 5 bytes, with the id = 2(can be a msg of anything) and a string with 3 bytes(" 3 'h' 'i' '!' " can indicate a string of 3 characters). The number 3 means that the next 3 bytes are the string I want to read. So strings have variable sizes. 2+lenght(string) bytes.
5 2 3 'h' 'i' '!'
That can be interpreted as a packet with 5 bytes, with the id = 2(can be a msg of anything) and a string with 3 bytes(" 3 'h' 'i' '!' " can indicate a string of 3 characters). The number 3 means that the next 3 bytes are the string I want to read. So strings have variable sizes. 2+lenght(string) bytes.