This was something I was planning on adding, but it was not applied to
the 4.2.0 branch, because it introduces a feature enhancement (storing a
global last error) and not a bug fix. It is a very simple enhance, I
just have not had the time to work on it yet.

-Jason



On Sat, 2002-04-27 at 07:22, Markus Fischer wrote:
>     Hi,
> 
>     socket_create() doesn't expose an error if one occurs when
>     creating a new socket with socket(). The current code is:
> 
> [...]
>     php_sock->bsd_socket = socket(arg1, arg2, arg3);
>     php_sock->type = arg1;
> 
>     if (IS_INVALID_SOCKET(php_sock)) {
>         efree(php_sock);
>         RETURN_FALSE;
>     }
> 
>     ZEND_REGISTER_RESOURCE(return_value, php_sock, le_socket);
> }
> 
>     This logic silently hides the error if we encounter one
>     during socket creating.
> 
> 
>     Since the current socket error reporting facility only
>     operates with a valid socket resource context we have a
>     limitation here because obviously there's no valid socket
>     resource context here (false is returned and we don't have
>     the socket resource yet).
> 
> 
>     Suggestion:
>     Introduce a (per thread) global variable which always stores
>     the error message of the last socket function which failed
>     and teach socket_last_error() to return this value if no
>     resource is passed to it, e.g.:
> 
>     if (false == (socket_create(...))) {
>         echo "Failed, reason:", socket_strerror(socket_last_error()), "\n";
>         [...]
>     }
> 
>     To be consistent with the other socket_*() functions I also
>     suggest emitting an E_WARNING message if it fails (basically
>     all other functions have been rewritten this way).
> 
>     I haven't included a patch because it's rather trivial.
> 
>     Any objections or better suggestions how to handle this?
> 
>     - Markus
> 
> -- 
> Please always Cc to me when replying to me on the lists.
> GnuPG Key: http://guru.josefine.at/~mfischer/C2272BD0.asc
> "Mind if I MFH ?" "What QA did you do on it?" "the usual?" "ah... none :)"
> 
> -- 
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to