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.
I'm thinking and thinking about this issue long time. I inspired ruby's
errno module (
http://www.ruby-doc.org/docs/ProgrammingRuby/html/ref_m_errno.html) and I
just wrote errno extension to check my idea. I think importing errno module
is not a bad idea.
https://github.com/chobie/php-errno/blob/master/php_errno.c
(currently, this lacks const_missing feature so this does not work on some
platform. )
Could you help me out if you guys have good solution about handling socket
error?
Thanks,
Shuhei
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
The socket extension has another problem. it cannot create persistent
connection.
this is a big problem on large web application.
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.
that approach is just came up and working sample. I'm looking for phpish
errno handling.
at least I need errno constants. you know errno depends platform. if I
hardcoded errno magic number on my library,
it works some platform but it might not work another platform (e.g
windows...)
I can choose to ignore errno on my library. but I'd like to improve PHP. as
PHP has libevent and some ev* extension
so adding errno feature is not a bad idea i think.
On Thu, Apr 4, 2013 at 6:34 AM, Gustavo Lopes glopes@nebm.ist.utl.ptwrote:
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