> Right? Right. The way I do it, very roughly: Pqconnectdb(...) PQexec( mDbConn, "listen notify" ); int dbsock = PQsocket( mDbConn ); mKq = kqueue(); struct kevent kev[1], kevs[1]; EV_SET( &kev[0], dbsock, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, 0 ); kevent( mKq, kev, 1, NULL, 0, NULL ); while( true ) { bool needsnotify = false; int evtcnt = kevent( mKq, NULL, 0, kevs, 1, NULL ); if( evtcnt == 1 && kevs[i].filter == EVFILT_READ && kevs[i].ident == dbsock ) { while( true ) { PQconsumeInput( mDbConn ); PGnotify * notify = PQnotifies( mDbConn ); if( notify ) { free( notify ); needsnotify = true; } else break; } } if( needsnotify ) // go off & query the db & handle updates here } Of course you could also use select to wait on the socket. -- Scott Ribe scott_ribe@xxxxxxxxxxxxxxx http://www.killerbytes.com/ (303) 722-0567 voice -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general