Network Source

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Network Source

      Hi, I took a look at the network code and found something I dont really understand why its done, namely in the constructor of the TextPacket class.

      This is the code:

      TextPacket::TextPacket(char const * const text)
      :BinaryPacket(static_cast<u_long>(strlen(text) + 2))
      MemCpy(text, strlen(text), 0);
      MemCpy("\r\n", 2, 2);
      *(u_long *)m_Data = 0;

      It first takes the input string and copies it to its internal buffer, thats ok. But then it copies a carriage return and line feed at position 2 of the new buffer, overwriting the content there. And finally the first 4 bytes containing the buffer size are set to 0.

      What is the reason for the last two lines?