keithyip
keithyip

Reputation: 1035

Linux socket buffered data size

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?

Upvotes: 3

Views: 1004

Answers (1)

caf
caf

Reputation: 239011

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.

Upvotes: 6

Related Questions