Code:
while (select(0, &sockets, 0, 0, &timeout))
{
test = recv(mysock, bufs, sizeof(bufs), 0);
if (test == 0)
{
cout << "Connection Closed\n";
return 1;
}
cout << bufs[0];
}
I'm pretty sure my error is in this code. It works on the first iteration (the whole thing is in an infinite for loop) but blocks on the second which suggests to me that the select is returning a value even though the socket isn't ready to read. Perhaps I'm simply using this wrong though. The other possibility is that select is returning some kind of error that I'm simply not checking for but how would I distinguish? BTW, I'm receiving everything in a single char at a time but I figured that would be safest.
I'm sure I'm just making a stupid and obvious mistake but I can't figure it out.
Thanks for all of the help.
PetrolMan