X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3F1E152918 for ; Thu, 30 Jun 2005 07:57:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86949-09 for ; Thu, 30 Jun 2005 10:57:34 +0000 (GMT) Received: from smtp.nildram.co.uk (smtp.nildram.co.uk [195.112.4.54]) by svr1.postgresql.org (Postfix) with ESMTP id 02390529C0 for ; Thu, 30 Jun 2005 07:57:30 -0300 (ADT) Received: from HYDROGEN (unknown [62.3.216.34]) by smtp.nildram.co.uk (Postfix) with ESMTP id 9D3E124D2D3; Thu, 30 Jun 2005 11:57:30 +0100 (BST) From: "Nick Stone" To: "'Volkan YAZICI'" Cc: Subject: Re: Pqsocket not implemented in PHP Date: Thu, 30 Jun 2005 11:55:28 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.6353 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AcV9XE4PDgfCHw7BQPmoHfzbQ5QzHwABKD9g In-Reply-To: <7104a7370506300310710e365c@mail.gmail.com> Message-Id: <20050630105730.9D3E124D2D3@smtp.nildram.co.uk> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200506/27 X-Sequence-Number: 3186 Hi, Thanks for the response - though I'm a bit confused the FD is all that is required for the select call - so I think what you're saying is that the postgres socket open mechanism isn't the same in php as the postgres C development library. I say this because I've implemented this exact mechanism in C++ before without problem so I'm really not quite following - sorry. Is it that PHP implements the underlying socket mechanism in a different way? I guess I'm not quite understanding could you give me a few more details of the PHP mechanism. Many thanks Nick -----Original Message----- From: pgsql-php-owner@postgresql.org [mailto:pgsql-php-owner@postgresql.org] On Behalf Of Volkan YAZICI Sent: 30 June 2005 11:11 To: Nick Stone Cc: pgsql-php@postgresql.org Subject: Re: [PHP] Pqsocket not implemented in PHP Hi, On 6/30/05, Nick Stone wrote: > I'm currently implementing a standalone app using php cli. Part of the > app connects to Postgres and waits for a notification using the > "Listen " SQL. In the postgres C lib there is a function > called "Pqsocket" which returns the file-descriptor of the socket > connection to Postgres. With this I can use a simple select server to > sleep on this interface and others in the application. > > Does anybody now of a patch to make this available under PHP or does > the structure of PHP code effectively make this type approach impossible? You can write a very simple patch returns socket FD using PQsocket(). But, AFAIC, it's not as simple as it seems to listen a socket using just its FD value. As I understand from the source code, resource required by socket_open() function has its own internal struct representation, which means you need to be familiar with PHP internal data types and mechanism before writing a patch. Therefore, it's not impossible to implement such a feature, but, to be honest, it needs a hard work. IMHO, you can enter a loop with pg_last_notice() by using usleep(). I won't think it'd cost so much system resource for you. Regards. ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend