Closed MilowB closed 3 years ago
@MilowB thank you for taking the time to write this. However, the buffer variable will get erased automatically (since it is allocated on the stack) at the end of each while iteration, and then will be created again on the next iteration. If the buffer is of size N, and the incoming message is of size M where N < M, then this is also not an issue since we pass the actual incoming message size to the observers, so can they read only M bytes.
For a reason I don't really understand, the msg buffer doesn't seem to get empty at the end of the loop. (The end of a long message can be read on the next shorter message received from the same socket). The memset function allows to empty the buffer before reusing it.