Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66929 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10050 invoked from network); 3 Apr 2013 21:34:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Apr 2013 21:34:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.21 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.21 smtp1.ist.utl.pt Linux 2.6 Received: from [193.136.128.21] ([193.136.128.21:43024] helo=smtp1.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 25/39-07534-970AC515 for ; Wed, 03 Apr 2013 16:34:50 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 681007000447; Wed, 3 Apr 2013 22:34:46 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp1.ist.utl.pt ([127.0.0.1]) by localhost (smtp1.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id jNVHv03EZDug; Wed, 3 Apr 2013 22:34:46 +0100 (WEST) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 232F67000436; Wed, 3 Apr 2013 22:34:46 +0100 (WEST) Received: from damnation.nl.lo.geleia.net (unknown [IPv6:2001:470:94a2:4:222:fbff:fe79:e0f0]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 483F120084B8; Wed, 3 Apr 2013 22:34:45 +0100 (WEST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net, chobie References: Date: Wed, 03 Apr 2013 23:34:42 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?utf-8?Q?N=C3=BAcleo_de_Eng=2E_Biom=C3=A9di?= =?utf-8?Q?ca_do_I=2ES=2ET=2E?= Message-ID: In-Reply-To: User-Agent: Opera Mail/12.14 (Linux) Subject: Re: [PHP-DEV] how to determine errno on user space? From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") On Tue, 02 Apr 2013 02:11:24 +0200, chobie 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