Bug #16819 Updated: FormatMessage and WSAGetLastError
| From: | jason@php.net | Date: | Mon, 01 Jul 2002 20:51:57 +0000 |
| Subject: | Bug #16819 Updated: FormatMessage and WSAGetLastError | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-12715@lists.php.net to get a copy of this message | ||
ID: 16819
Updated by: jason@php.net
Reported By: Nofin@Mail2K.ru
-Status: Open
+Status: Bogus
Bug Type: Sockets related
Operating System: Windows' 9x
PHP Version: 4.1.2
New Comment:
Thank you for taking the time to report a problem with PHP.
Unfortunately your version of PHP is too old -- the problem
might already be fixed. Please download a new PHP
version from http://www.php.net/downloads.php
If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.
Could you try a later version, the sockets extension has changed
significantly since 4.1.X, and reopen if it is a problem?
Thanks,
Jason
Previous Comments:
------------------------------------------------------------------------
[2002-04-26 01:31:49] Nofin@Mail2K.ru
For the best understanding of a problem I bring endurance from the
"Winsock Programmer's FAQ":
>> Note that some people will tell you that the Win32 FormatMessage()
API can be coerced into returning error messages for Winsock error
numbers. At best, this is undocumented behavior that only works with
some implementations of Winsock. I personally have not been able to get
it to work, despite significant time devoted to the problem. My advice
is that you're much better off spending your time constructing
meaningful error messages than chasing something that could never work
very well even if it was documented behavior. <<
Also in this book there is an example how to receive the textual
message on an error from a code of an error.
If you want I can to you it(him) send.
I think that it is necessary to produce some modifications in functions
("socket.c": "php_strerror", "socket_strerror") , in connection with
described above.
------------------------------------------------------------------------
[2002-04-25 18:34:03] alindeman@php.net
I fixed the return value part of the bug
------------------------------------------------------------------------
[2002-04-25 06:20:05] Nofin@Mail2K.ru
2) Function "socket_connect" (/ext/sockets/socket.c) calls function
php_error:
....
php_error(E_WARNING, "%s() %s [%d]: %s",
get_active_function_name(TSRMLS_C), msg, errn, php_strerror(errn));
...
but last parameter is not a pointer to string, it's an integer number
(equals to "errn"), because "php_strerror(errn)" can not return error
message (function "FormatMessage" fails).
------------------------------------------------------------------------
[2002-04-25 06:16:01] Nofin@Mail2K.ru
1) in your documentation
(http://www.php.net/manual/en/function.socket-connect.php)
"socket_connect" function described as:
int socket_connect ( resource socket, string address [, int port])
but in your binaries (extensions/php_sockets.dll) and in
source codes (/ext/sockets/socket.c) this function returns 0(false) or
1(true):
...
if (retval != 0)
{
PHP_SOCKET_ERROR(php_sock, "unable to connect", errno);
RETURN_FALSE;
}
RETURN_TRUE;
...
Also "Example 2. Socket example: Simple TCP/IP client"
(http://www.php.net/manual/en/ref.sockets.php) is wrong:
...
$socket = socket_create (AF_INET, SOCK_STREAM, 0);
if ($socket < 0) {
echo "socket_create() failed: reason: " . socket_strerror ($socket)
. "\n";
} else {
echo "OK.\n";
}
...
Must be something like this:
...
if ($socket == 0) {
...
2) Function "socket_connect" (/ext/sockets/socket.c) calls function
php_error:
....
php_error(E_WARNING, "%s() %s [%d]: %s",
get_active_function_name(TSRMLS_C), msg, errn, php_strerror(errn));
...
but last parameter is not a pointer to string, it's an integer number
(equals to "errn"), because "php_strerror(errn)" can not return error
message (function "FormatMessage" fails).
------------------------------------------------------------------------
[2002-04-25 06:15:23] mfischer@php.net
Yes, known thx. It's a documentation issue.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/16819
--
Edit this bug report at http://bugs.php.net/?id=16819&edit=1