bool wait_for_action( unsigned timeout_millis ) {
socket_type select_fd = m_socket;
int rdy;
fd_set wakeup;
struct timeval timeout;
FD_ZERO( &wakeup );
FD_SET( select_fd, &wakeup );
timeout.tv_sec = timeout_millis / 1000;
timeout.tv_usec = (timeout_millis % 1000) * 1000;
int ndfs = select_fd + 1;
if( (rdy = select( ndfs, &wakeup, 0, 0, &timeout )) == c_socket_error )
{
throw exception( "select failed. (%d)", get_errorno() );
}
return (rdy == 0) ? false : true; // rdy becomes 0 after a few frames
}