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 1851C529A6 for ; Thu, 30 Jun 2005 07:10:56 -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 79548-02 for ; Thu, 30 Jun 2005 10:10:46 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.203]) by svr1.postgresql.org (Postfix) with ESMTP id CFEF1529BE for ; Thu, 30 Jun 2005 07:10:45 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id i21so66260wra for ; Thu, 30 Jun 2005 03:10:48 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=MQ11QnI4ylKCW8xr+MgRBSu+zc+XyVSpW6CbQm51tJ8LobMM/Th9qvbDxhDeFkE9kRDYlv0MO2XGrCgbcavq+voSn6EYW2x/l1J+MRd5Wo1OrK/HBaUSzu+/YRj/k5KS386bn0YYP4pp3bRzuNRZsFIUI2sBNRKq0BxUlkySMJE= Received: by 10.54.18.22 with SMTP id 22mr272987wrr; Thu, 30 Jun 2005 03:10:48 -0700 (PDT) Received: by 10.54.30.45 with HTTP; Thu, 30 Jun 2005 03:10:48 -0700 (PDT) Message-ID: <7104a7370506300310710e365c@mail.gmail.com> Date: Thu, 30 Jun 2005 13:10:48 +0300 From: Volkan YAZICI Reply-To: Volkan YAZICI To: Nick Stone Subject: Re: Pqsocket not implemented in PHP Cc: pgsql-php@postgresql.org In-Reply-To: <20050630093709.3A198252676@smtp.nildram.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20050630093709.3A198252676@smtp.nildram.co.uk> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.126 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200506/26 X-Sequence-Number: 3185 Hi, On 6/30/05, Nick Stone wrote: > I'm currently implementing a standalone app using php cli. Part of the ap= p > 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. >=20 > 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.