Unknown inet_ntop / inet_pton IPv6 Error

Hello,

What would cause these two scripts (shown in their entirety) to generate the following errors?

<?php
	echo inet_pton('::1');
?>

Warning: inet_pton(): Unrecognized address ::1 in C:\Program Files\PHP\ est.php on line 2

<?php
	echo inet_ntop(str_repeat("\\0", 15)."\\1");
?>

Warning: inet_ntop(): An unknown error occured in C:\Program Files\PHP\ est.php on line 2

This error occurs when the script is run from Apache or from the CLI. The code is running under Windows XP SP3. PHP reports that IPv6 support is enabled when using [fphp]phpinfo[/fphp].

Here’s the PHP version info:

PHP 5.3.1 (cli) (built: Nov 19 2009 10:17:43)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
    with Xdebug v2.1.0rc1-dev, Copyright (c) 2002-2010, by Derick Rethans

I couldn’t find anything when searching and the error messages themselves aren’t particularly helpful.

Thanks for any insights! :slight_smile:

The problem is solved. The underlying operating system (XP SP3) didn’t have IPv6 support enabled. Since PHP makes a system call to the OS in order to do the heavy lifting, and the OS didn’t support or understand IPv6, the command was failing. The “Unknown Error” and “Unrecognizable Address” errors appear when the problem occurs at this lower level.

On XP SP3, IPv6 support can be enabled by executing this command:

netsh interface ipv6 install

I’ll leave this post here to help others who may encounter the same enigmatic error in the future.

P.S. When you are developing software, PLEASE do not ever return an “unknown error!” At least give us SOME clue about what went wrong! :nono: