public function listen(Io $io, float $timeout = 0)
{
$resource = $io->getResource();
$id = (int) $resource;
if (!isset($this->sockets[$id]) || $io !== $this->sockets[$id]) {
throw new FreedError();
}
$this->pending[$id] = $resource;
if (isset($this->timers[$id])) {
$this->timers[$id]->stop();
}
if ($timeout) {
if (self::MIN_TIMEOUT > $timeout) {
$timeout = self::MIN_TIMEOUT;
}
$this->timers[$id] = $this->loop->timer($timeout, false, $this->timerCallback, $io);
}
}