<HTML ><HEAD ><TITLE >Asynchronous Notification</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.64 "><LINK REV="MADE" HREF="mailto:pgsql-docs@postgresql.org"><LINK REL="HOME" TITLE="libpq++ - C++ Binding Library" HREF="index.html"><LINK REL="PREVIOUS" TITLE="Query Execution Functions" HREF="libpqpp-exec.html"><LINK REL="NEXT" TITLE="Functions Associated with the COPY Command" HREF="libpqpp-copy.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="stylesheet.css"><META NAME="creation" CONTENT="2002-11-27T04:23:11"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" ><SPAN CLASS="APPLICATION" >libpq++</SPAN > - C++ Binding Library</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="libpqpp-exec.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="libpqpp-copy.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="libpqpp-notify" >1.6. Asynchronous Notification</A ></H1 > <P > <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > supports asynchronous notification via the <TT CLASS="COMMAND" >LISTEN</TT > and <TT CLASS="COMMAND" >NOTIFY</TT > commands. A backend registers its interest in a particular notification condition with the <TT CLASS="COMMAND" >LISTEN</TT > command. All backends that are listening on a particular condition will be notified asynchronously when a <TT CLASS="COMMAND" >NOTIFY</TT > of that name is executed by another backend. No additional information is passed from the notifier to the listener. Thus, typically, any actual data that needs to be communicated is transferred through a relation. </P > <P > <SPAN CLASS="APPLICATION" >libpq++</SPAN > applications are notified whenever a connected backend has received an asynchronous notification. However, the communication from the backend to the frontend is not asynchronous. The <SPAN CLASS="APPLICATION" >libpq++</SPAN > application must poll the backend to see if there is any pending notification information. After the execution of a command, a frontend may call <TT CLASS="FUNCTION" >PgDatabase::Notifies</TT > to see if any notification data is currently available from the backend. <TT CLASS="FUNCTION" >PgDatabase::Notifies</TT > returns the notification from a list of unhandled notifications from the backend. The function returns <TT CLASS="SYMBOL" >NULL</TT > if there are no pending notifications from the backend. <TT CLASS="FUNCTION" >PgDatabase::Notifies</TT > behaves like the popping of a stack. Once a notification is returned from <TT CLASS="FUNCTION" >PgDatabase::Notifies</TT >, it is considered handled and will be removed from the list of notifications. <P ></P ></P><UL ><LI > <P > <TT CLASS="FUNCTION" >PgDatabase::Notifies</TT > retrieves pending notifications from the server. </P><PRE CLASS="SYNOPSIS" >PGnotify* PgDatabase::Notifies()</PRE ><P> </P > </LI ></UL ><P> </P > <P > The second sample program gives an example of the use of asynchronous notification. </P > </DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="libpqpp-exec.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="libpqpp-copy.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Query Execution Functions</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" > </TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Functions Associated with the COPY Command</TD ></TR ></TABLE ></DIV ></BODY ></HTML >