Waits for a connection