On Tue, 02 Apr 2013 02:11:24 +0200, chobie <chobi...@gmail.com> wrote:

Hi, I'm writing some socket client (fluentd client) with PHP and I have a
question.

I want to retry fwrite or some socket function when I met recoverable errno (e.g, EAGAIN). but PHP does not have any function to determine errno as far as I known.

what is the correct way to handle errno?
I'd like to write robust client with PHP but I don't have good idea to
determine errno.


The sockets extension has socket_last_error() to get the errno value after the last operation on the passed in socket.

The stream functions don't really handle this in a consistent fashion. For instance, stream_socket_client() can take a parameter by reference where to write the errno value, but other functions do not give such information and can only inform the user about the specific error that occurred via the a warning, which is not very friendly for programatically extracting the cause. I'd recommend that you use the sockets extension, unless you need encryption.

As to your approach, I don't really like it. PHP does not have enumerations, and the approach of creating a very large number of classes for this purpose is unprecedented in the PHP codebase.

--
Gustavo Lopes

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

Reply via email to