
SwooleConnectionIterator::next를 사용하여 연결을 순회하는 중에 발생하는 오류는 Resource ID #N/A 오류입니다.
이러한 오류는 SwooleConnectionIterator::next를 호출하기 전에 rewind() 메소드를 호출하지 않아서 발생합니다.
SwooleConnectionIterator는 연결을 순회할 때 Iterator를 사용하기 때문에 rewind() 메소드를 호출하여 Iterator의 포인터를 처음 위치로 이동해야 합니다.
정확한 소스를 작성하기 위해서는 SwooleConnectionIterator::next를 호출하기 전에 rewind() 메소드를 호출해야 합니다.
#hostingforum.kr
php
$iterator = new SwooleConnectionIterator();
$iterator->add($connection);
$iterator->rewind(); // rewind() 메소드를 호출하여 Iterator의 포인터를 처음 위치로 이동
while ($iterator->valid()) {
$nextConnection = $iterator->next();
// ...
}
또한, SwooleConnectionIterator::next를 호출할 때 null을 반환할 수 있습니다. 이 경우는 연결이 더 이상 존재하지 않는 경우입니다.
따라서, SwooleConnectionIterator::next를 호출할 때 null을 반환하는 경우를 처리해야 합니다.
#hostingforum.kr
php
while ($iterator->valid()) {
$nextConnection = $iterator->next();
if ($nextConnection) {
$this->log->debug('next connection');
} else {
$this->log->error('next connection is null');
}
}
2025-05-08 09:07