add usleep to prevent 100% cpu while looping connect()