$ip = '127.0.0.1';
// Get a new instance
- $helper = new ConsoleTools();
+ $helperInstance = new ConsoleTools();
try {
// Get a file pointer
$io->closeFile();
// Resolve the IP number
- $ip = $helper->resolveIpAddress($hostname);
+ $ip = $helperInstance->resolveIpAddress($hostname);
} catch (FileIoException $e) {
// Fall-back to 'SESSION_SVR' which found on my Sun Station
if (isset($_SERVER['SESSION_SVR'])) {
// Resolve it
- $ip = $helper->resolveIpAddress($_SERVER['SESSION_SVR']);
+ $ip = $helperInstance->resolveIpAddress($_SERVER['SESSION_SVR']);
} else {
// Could not find our hostname
- $helper->debugOutput(sprintf("[%s:] WARNING: Cannot resolve my own IP address.",
- $helper->__toString()
+ $helperInstance->debugOutput(sprintf("[%s:] WARNING: Cannot resolve my own IP address.",
+ $helperInstance->__toString()
));
}
} catch (FrameworkException $e) {
// Output debug message
- $helper->debugOutput(sprintf("[%s:] Problem while resolving own IP address: [%s|%s]:%s",
- $helper->__toString(),
+ $helperInstance->debugOutput(sprintf("[%s:] Problem while resolving own IP address: [%s|%s]:%s",
+ $helperInstance->__toString(),
$e->__toString(),
$e->getHexCode(),
$e->getMessage()
* @return $externalAddress The determined external IP address
* @throws InvalidSocketException If socket initialization wents wrong or if an errors occurs
*/
- public function determineExternalIp ($dest = '217.172.186.31', $port = 80) {
+ public static function determineExternalIp ($dest = '217.172.186.31', $port = 80) {
+ // Get helper instance
+ $helperInstance = new ConsoleTools();
+
// First get a socket
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
// Is it valid?
if (!is_resource($socket)) {
// Throw InvalidSocketException
- throw new InvalidSocketException (array($this, gettype($socket), 0, 'unknown'));
+ throw new InvalidSocketException (array($helperInstance, gettype($socket), 0, 'unknown'));
} // END - if
// Get socket error code for verification
// Check if there was an error else
if ($socketError > 0) {
// Then throw again
- throw new InvalidSocketException(array($this, gettype($socket), $socketError, socket_strerror($socketError)), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($helperInstance, gettype($socket), $socketError, socket_strerror($socketError)), BaseListener::EXCEPTION_INVALID_SOCKET);
} // END - if
// Connect to the destination