The bug is in the usleep(), HTTP_WAIT needs to be converted to microseconds.