LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   fseek on a socket descriptor to discard socket buffer? (https://www.linuxquestions.org/questions/programming-9/fseek-on-a-socket-descriptor-to-discard-socket-buffer-389741/)

Thinking 12-06-2005 07:00 AM

fseek on a socket descriptor to discard socket buffer?
 
hiho@ll

i have a simple protocol which sends the data size and then the data itself

the function which reads the data gets a char pointer and the size of the char buffer

now i read the size of the data which should be available
and then i read the data in the buffer
if the buffersize < datasize i want to discard the rest of the data which is available

do i have to use read(); until there is no more data, or can i do something like a fseek(); on the stream? or is there a function which can discard the next n bytes which become available?

thx@ll

taylor_venable 12-06-2005 10:15 PM

I don't think fseek() will work; I believe this situation would qualify as a "non-seekable stream". I would just keep read() ing until there's nothing left.


All times are GMT -5. The time now is 10:39 AM.