I'm having a really hard time understanding why is this piece of code making my computer beep. I've isolated this section of code to be the one producing the occasional beep, but I don't see what's the problem with it.
const int BUFFER_LENGTH = 8192;
char buffer [BUFFER_LENGTH + 1];
int recvResult;
do
{
recvResult = recv(webSocket, buffer, BUFFER_LENGTH, 0);
buffer[recvResult] = '\0';
printf("%s", buffer);
if (recvResult > 0)
{
sendResult = send(clientSocket, buffer, recvResult, 0);
}
}while (recvResult > 0);
shutdown(webSocket, SD_SEND);
To give a little bit of context, this is for a computer networks class in which we have to code a proxy. So what I'm doing is listening to the answer and simply forward it to the client.
I can't tell you how high I jumped out of my chair when I first heard the beeping noise...