views:

40

answers:

1

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
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.