original_string: public static function isPortOpen($host, $port, $protocol)
      {
          $protocol = strtolower($protocol);
          
          if ($protocol != 'tcp' && $protocol != 'udp')
          {
              $errMsg = 'Unrecognized protocol [' . $protocol . '] ' . 
                        'please specify [tcp] or [udp]';
              throw new \Exception($errMsg);
          }
          
          if (empty($host))
          {
              $host = self::getPublicIp();
          }
  
          foreach ($ports as $port)
          {
              $connection = @fsockopen($host, $port);
  
              if (is_resource($connection))
              {
                  $isOpen = true;
                  fclose($connection);
              }
  
              else
              {
                  $isOpen = false;
              }
          }
          
          return $isOpen;
      }
code: public static function isPortOpen($host, $port, $protocol)
      {
          $protocol = strtolower($protocol);
          
          if ($protocol != 'tcp' && $protocol != 'udp')
          {
              $errMsg = 'Unrecognized protocol [' . $protocol . '] ' . 
                        'please specify [tcp] or [udp]';
              throw new \Exception($errMsg);
          }
          
          if (empty($host))
          {
              $host = self::getPublicIp();
          }
  
          foreach ($ports as $port)
          {
              $connection = @fsockopen($host, $port);
  
              if (is_resource($connection))
              {
                  $isOpen = true;
                  fclose($connection);
              }
  
              else
              {
                  $isOpen = false;
              }
          }
          
          return $isOpen;
      }
code_tokens: public static function isPortOpen ( $ host , $ port , $ protocol ) { $ protocol = strtolower ( $ protocol ) ; if ( $ protocol != 'tcp' && $ protocol != 'udp' ) { $ errMsg = 'Unrecognized protocol [' . $ protocol . '] ' . 'please specify [tcp] or [udp]' ; throw new \ Exception ( $ errMsg ) ; } if ( empty ( $ host ) ) { $ host = self :: getPublicIp ( ) ; } foreach ( $ ports as $ port ) { $ connection = @ fsockopen ( $ host , $ port ) ; if ( is_resource ( $ connection ) ) { $ isOpen = true ; fclose ( $ connection ) ; } else { $ isOpen = false ; } } return $ isOpen ; }
docstring: Checks to see if the specified port is open.
  @param string $host - the host to check against.
  @param int $port - the port to check
  @return $isOpen - true if port is open, false if not.
docstring_tokens: Checks to see if the specified port is open .