PHPDaemon\Clients\ICMP\Connection::onRead PHP Метод

onRead() публичный Метод

Called when new data received
public onRead ( ) : void
Результат void
    public function onRead()
    {
        $packet = $this->read(1024);
        $orig = $packet;
        $type = Binary::getByte($packet);
        $code = Binary::getByte($packet);
        $checksum = Binary::getStrWord($packet);
        $id = Binary::getWord($packet);
        $seq = Binary::getWord($packet);
        if ($checksum !== self::checksum(substr_replace($orig, "", 2, 2))) {
            $status = 'badChecksum';
        } elseif ($type === 0x3) {
            $status = isset(static::$unreachableCodes[$code]) ? static::$unreachableCodes[$code] : 'unk' . $code . 'unreachable';
        } else {
            $status = 'unknownType0x' . dechex($type);
        }
        while (!$this->onResponse->isEmpty()) {
            $el = $this->onResponse->shift();
            if ($el instanceof CallbackWrapper) {
                $el = $el->unwrap();
            }
            list($cb, $st) = $el;
            $cb(microtime(true) - $st, $status);
        }
        $this->finish();
    }