Is there any simple functions to check how much data is buffered but unread? FD_ISSET only indicates the presence of data in the buffer. Is possible not to create a second buffer in the program for greater control of buffer?
+4
A:
You could use recv()
with the MSG_PEEK
and MSG_DONTWAIT
flags, but there's no firm guarantee that there aren't more bytes available than recv()
returned in that case.
Using a buffer within your program is the normal and accepted way to solve the problem.
caf
2010-07-31 04:18:11
This helps a lot! Although peek move the data one more time, it let me quickly test the system buffer usage. I decide create a thread to move the data from system buffer to program buffer.
2010-08-03 16:15:11