/** * Process I/O operations on sockets * * @param SocketBag $socketBag Socket bag * * @return void * @throws \Exception */ public function process(SocketBag $socketBag) { do { $activeOperations = $this->connectStage->processStage($socketBag->getItems()); if (!$activeOperations) { break; } foreach ($this->stages as $stage) { $activeOperations = $stage->processStage($activeOperations); } } while (true); }
/** * Shutdown all sockets in case of unhandled exception * * @return void */ private function emergencyShutdown() { foreach ($this->socketBag->getItems() as $item) { try { $item->getSocket()->close(); } catch (\Exception $e) { // nothing required } $item->setMetadata(self::META_REQUEST_COMPLETE, true); } }