std::array<char, 256> buffer;
while (1) { // top loop
while (1) { // inner loop
n = recv(sockfd, &buffer[0], buffer.size() - 1, 0);
if (n == 0) {
break;
}
memset(buffer.data(), 0, 256);
}
n = send(sockfd, "33", 3, MSG_NOSIGNAL);
}
I think that in one by one top loop, "recv" is blocked without "send". But In this code, first "recv" is blocked, but the infinite non-blocking loop occurs after "recv" is worked by one "send". I don't any "send" except for the first "send". In infinite loop, buffer size is 0 and, "n" is 0. I don't know why...