move usleep outside the recv loop