Use select() to wait on non-blocking socket