Misa Simic wrote:
> I am not a C developer - was not aware about select()... I was read it as
> some kind of sleep...
php provides socket_select() as an equivalent to C's select().
See http://php.net/manual/en/function.socket-select.php
But it takes "socket resources" as arguments and the postgres php layer
does not provides a conversion from the file descriptor returned by
PQsocket() to such php socket resources.
Thus socket_select() can't be used to monitor a postgres connection.
However, you can get a behavior that's close enough in practice to
select() with code like this:
pg_query($conn, "LISTEN event_name");
while (!$end) {
$arr=pg_get_notify($conn);
if (!$arr) {
usleep(100000);
}
else
// process the notification
}
This will catch a notification 1/10 second max after it's available and sleep
the rest of the time.
Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org