当前位置: 首页>>代码示例>>PHP>>正文


PHP Network::is_port_open方法代码示例

本文整理汇总了PHP中Network::is_port_open方法的典型用法代码示例。如果您正苦于以下问题:PHP Network::is_port_open方法的具体用法?PHP Network::is_port_open怎么用?PHP Network::is_port_open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Network的用法示例。


在下文中一共展示了Network::is_port_open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ephimeral_port

 /**
  * Find an open port in a given range, trying several times.
  * Return FALSE if no open port is found after a timeout (1 second by default)
  *
  * @param  string  $host
  * @param  integer $range_start
  * @param  integer $range_end
  * @param  integer $timeout
  * @return integer|boolean
  */
 public static function ephimeral_port($host, $range_start = 1000, $range_end = 5000, $timeout = 1000)
 {
     return Attempt::make(function () use($host, $range_start, $range_end) {
         $port = rand($range_start, $range_end);
         return Network::is_port_open($host, $port) ? $port : FALSE;
     }, $timeout);
 }
开发者ID:openbuildings,项目名称:spiderling,代码行数:17,代码来源:Network.php

示例2: start

 /**
  * Start a phantomjs server in the background. Set port, server js file, additional files and log file.
  *
  * @param  string $file       the server js file
  * @param  integer $port      the port to start the server on
  * @param  string $additional additional file, passed to the js server
  * @param  string $log_file
  * @return string             the pid of the newly started process
  */
 public static function start($file, $port, $additional = NULL, $log_file = '/dev/null')
 {
     if (!Network::is_port_open('localhost', $port)) {
         throw new Exception('Port :port is already taken', array(':port' => $port));
     }
     if ($log_file !== '/dev/null' and !is_file($log_file)) {
         throw new Exception('Log file (:log_file) must be a file or /dev/null', array(':log_file' => $log_file));
     }
     return shell_exec(strtr('nohup :command > :log 2> :log & echo $!', array(':command' => self::command($file, $port, $additional), ':log' => $log_file)));
 }
开发者ID:openbuildings,项目名称:spiderling,代码行数:19,代码来源:Phantomjs.php

示例3: is_running

 /**
  * Check if the phantomjs server is actually running (the port is taken)
  * @return boolean
  */
 public function is_running()
 {
     return !Network::is_port_open($this->host(), $this->port());
 }
开发者ID:openbuildings,项目名称:spiderling,代码行数:8,代码来源:Connection.php


注:本文中的Network::is_port_open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。