[PATCH v2 5/6] change rlWaitForSocket to use shared code