ReceiveThreadFunction receives max 1024 bytes and then adds '\0' to it, so the buffer needs to be 1025 chars.