/** * @inheritDoc */ public static function create($components) { // set timeout $placeArmies = new self(); $placeArmies->setTimeout($components[2]); return $placeArmies; }
/** * @inheritDoc */ public static function create($components) { // set timeout $pick = new self(); $pick->setTimeout($components[1]); $pick->setRegionIds(array_slice($components, 2)); return $pick; }
/** * Returns client with newly created ZeroMQ Socket * * @param array $servers list of addresses of servers * @param integer $timeout * @return ZeroMQClientTransport */ public static function create($servers, $timeout = 1) { $socket = new \ZMQSocket(new \ZMQContext(), \ZMQ::SOCKET_REQ); $socket->setSockOpt(\ZMQ::SOCKOPT_LINGER, 0); foreach ((array) $servers as $server) { $socket->connect($server); } $client = new self($socket); $client->setTimeout($timeout); return $client; }
/** * @param array $params * @return UTIL_Ftp */ public static function getConnection(array $params) { if (!function_exists('ftp_connect')) { throw new LogicException(self::ERROR_FTP_FUNCTION_IS_NOT_AVAILABLE); } if (empty($params['host'])) { throw new InvalidArgumentException(self::ERROR_EMPTY_HOST_PROVIDED); } if (empty($params['login']) || empty($params['password'])) { throw new InvalidArgumentException(self::ERROR_EMPTY_CREDENTIALS_PROVIDED); } $connection = new self(); if (!empty($params['timeout'])) { $connection->setTimeout((int) $params['timeout']); } if (!$connection->connect(trim($params['host']), !empty($params['port']) ? (int) $params['port'] : 21)) { throw new LogicException(self::ERROR_CANT_CONNECT_TO_HOST); } if (!$connection->login(trim($params['login']), trim($params['password']))) { throw new LogicException(self::ERROR_INVALID_CREDENTIALS_PROVIDED); } $connection->init(); return $connection; }
/** * Метод принимает входящее подключение от удаленного хоста. * * @param null|float $timeout Тайм-аут операции. * @param null|string $peerName Ссылка на переменную, в которую будет помещено имя подключившегося хоста. * @return Ext_Io_Net_Stream * @throws Ext_Io_Net_Stream_Exception Будет выброшено, если стрим не в режиме сервера. */ public function accept($timeout = null, &$peerName = null) { $strPeerName = ''; if ($this->_type !== self::TYPE_SERVER) { throw new Ext_Io_Net_Stream_Exception('Can not accept connections on non listening stream', Ext_Io_Net_Stream_Exception::INVALID_STREAM_MODE); } if (is_null($timeout)) { $timeout = ini_get('default_socket_timeout'); } else { if ($timeout < 0) { throw new Ext_Io_Net_Stream_Exception('Invalid accept timeout', Ext_Io_Net_Stream_Exception::INVALID_TIMEOUT); } } $stream = new self(); $stream->_type = self::TYPE_CLIENT; $stream->setResource($this->_accept($timeout, $strPeerName)); $stream->setTimeout($this->_timeout['sec'], $this->_timeout['usec']); return $stream; }
/** * @param array $params * @return UTIL_Ftp */ public static function getConnection(array $params) { if (empty($params['host'])) { throw new InvalidArgumentException('Empty host provided for connection'); } $connection = new self(); if (!empty($params['timeout'])) { $connection->setTimeout((int) $params['timeout']); } $connected = $connection->connect(trim($params['host']), !empty($params['port']) ? (int) $params['port'] : 21); if (!$connected) { throw new LogicException("Can't connect to host `" . trim($params['host']) . "` by FTP"); } if (!empty($params['login']) && !empty($params['password'])) { $connection->login(trim($params['login']), trim($params['password'])); } $connection->init(); return $connection; }
/** * @param \DOMElement $element * * @throws \InvalidArgumentException * @return self * * @todo define exception message */ public static function fromXml(\DOMElement $element) { $xpath = new \DOMXPath($element->ownerDocument); $xpath->registerNamespace('D', 'DAV:'); $xLockType = $xpath->query('D:locktype/*', $element); $xLockScope = $xpath->query('D:lockscope/*', $element); if ($xLockType->length == 0 || $xLockScope->length == 0) { throw new \InvalidArgumentException(); } $result = new self($xLockScope->item(0)->localName, $xLockType->item(0)->localName); if ($depth = $xpath->evaluate('string(D:depth)', $element)) { $result->setDepth(DepthHeader::parse($depth)); } if ($timeout = $xpath->evaluate('string(D:timeout)', $element)) { $result->setTimeout($timeout); } $xOwner = $xpath->query('D:owner', $element); if ($xOwner->length) { $result->setOwner(trim($xOwner->item(0)->textContent)); } $xLockToken = $xpath->query('D:locktoken', $element); if ($xLockToken->length) { $result->setToken(trim($xLockToken->item(0)->textContent)); } return $result; }