|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-04-25 06:13 UTC] Nofin at Mail2K dot 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). PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 16:00:01 2025 UTC |
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.