/** * Start connecting process * * @param RequestDescriptor $descriptor Socket operation data * * @return bool True if successfully connected, false otherwise */ private function connectSocket(RequestDescriptor $descriptor) { $descriptor->initialize(); $socket = $descriptor->getSocket(); $event = $this->createEvent($descriptor, EventType::INITIALIZE); try { $this->callSocketSubscribers($descriptor, $event); $this->setSocketOperationTime($descriptor, RequestExecutorInterface::META_CONNECTION_START_TIME); $meta = $descriptor->getMetadata(); $socket->open($meta[RequestExecutorInterface::META_ADDRESS], $this->getStreamContextFromMetaData($meta)); $descriptor->setRunning(true); $result = true; } catch (SocketException $e) { $descriptor->setMetadata(RequestExecutorInterface::META_REQUEST_COMPLETE, true); $this->callExceptionSubscribers($descriptor, $e); $result = false; } return $result; }