- while ((*li).c_str()[k])
- {
- buff[n % 8] = (*li).c_str()[k];
- n++;
- k++;
-
- if (n % 8 == 0)
- {
- EncodeString(buffS, buff, &ctx);
- int ret = send(sock, buffS, 8, 0);
- if (ret < 0)
- {
- return -1;
- }
- }
- }
- k = 0;// new node
- ++li;
+ char buffer[1024];
+ std::string::size_type chunkLength = std::min(length - pos, sizeof(buffer));
+ EncodeFullString(buffer, answer.c_str() + pos, chunkLength, ctx);
+ if (send(sock, buffer, chunkLength, 0) < 0)
+ return -1;
+ pos += chunkLength;