[PATCH v3 5/7] change rlWaitForSocket to use shared code