bool update(int _fd, int _timeout, char *buffer)...{ //cout << "update +++++++" << endl; fd_set fdClient; FD_ZERO( &fdClient ); FD_SET( _fd, &fdClient ); struct timeval tv; tv.tv_sec = _timeout; tv.tv_usec = 0; if( select( _fd + 1, &fdClient, NULL, NULL, &tv ) == -1 ) ...{ return true; } if( FD_ISSET( _fd, &fdClient ) ) ...{ memset( buffer, 0, sizeof( char ) * GPBUF_SIZE ); int c = recv( _fd, buffer, GPBUF_SIZE, 0 ); if( c == -1 && errno != EWOULDBLOCK ) ...{ if( errno != ECONNRESET ) //cout << "peer reset the connection" << endl; return true; } if( c == 0 ) return true; } return false; }