I needed a function to flush the incoming data buffer for a TCP socket
and wrote the function below. The problem is that when I kill the
server that the socket is connected to while flushing the buffer, recv()
doesn't return an error; it reads data from the socket infinitely.
And select() still reports the socket as ready to read from (I know
an error pending will cause this correct behavior though, but how do
I tell the difference between data ready or socket error?) Can anyone
help me with this? Is there a better approach to flushing the socket
buffer than the way I'm doing it here? Thanks for any help. -ekw
int tcpFlush(int socket)
struct timeval timeout;
select(socket+1, &rset, NULL, NULL, &timeout);
if( (status=recv(socket, &byte, 1, 0)) == -1)
Sent via Deja.com http://www.deja.com/Quote:}
Before you buy.