I'm getting a full file from a server, doing:
flags=fcntl(socknum,F_GETFL,NULL);
flags|=O_NONBLOCK;
fcntl(socknum,F_SETFL,flags);
while(read(socknum,&buffer,1)>0)
cout << (int)buffer << " - " << buffer << endl;
If I don't set the O_NONBLOCK flag this works fine, except that after the last character has been read, the next read() blocks, and I want it to exit the while(). But if I set the nonblocking flag, then it doesn't read a single character.
What am I missing?
Thanks.