</listitem>
</varlistentry>
<varlistentry id="libpq-PQcancelStatus">
<term><function>PQcancelStatus</function><indexterm><primary>PQcancelStatus</primary></indexterm></term>
<listitem>
<para>
Returns the status of the cancel connection.
<synopsis>
ConnStatusType PQcancelStatus(const PGcancelConn *cancelConn);
</synopsis>
</para>
<para>
The status can be one of a number of values. However, only three of
these are seen outside of an asynchronous cancel procedure:
<symbol>CONNECTION_ALLOCATED</symbol>,
<symbol>CONNECTION_OK</symbol> and
<symbol>CONNECTION_BAD</symbol>. The initial state of a
<function>PGcancelConn</function> that's successfully created using
<xref linkend="libpq-PQcancelCreate"/> is <symbol>CONNECTION_ALLOCATED</symbol>.
A cancel request that was successfully dispatched
has the status <symbol>CONNECTION_OK</symbol>. A failed
cancel attempt is signaled by status
<symbol>CONNECTION_BAD</symbol>. An OK status will
remain so until <xref linkend="libpq-PQcancelFinish"/> or
<xref linkend="libpq-PQcancelReset"/> is called.
</para>
<para>
See the entry for <xref linkend="libpq-PQcancelStart"/> with regards
to other status codes that might be returned.
</para>
<para>
Successful dispatch of the cancellation is no guarantee that the request
will have any effect, however. If the cancellation is effective, the
command being canceled will terminate early and return an error result.
If the cancellation fails (say, because the server was already done
processing the command), then there will be no visible result at all.
</para>
</listitem>
</varlistentry>
<varlistentry id="libpq-PQcancelSocket">
<term><function>PQcancelSocket</function><indexterm><primary>PQcancelSocket</primary></indexterm></term>
<listitem>
<para>
Obtains the file descriptor number of the cancel connection socket to
the server.
<synopsis>
int PQcancelSocket(const PGcancelConn *cancelConn);
</synopsis>
</para>
<para>
A valid descriptor will be greater than or equal to 0;
a result of -1 indicates that no server connection is currently open.
This might change as a result of calling any of the functions
in this section on the <structname>PGcancelConn</structname>
(except for <xref linkend="libpq-PQcancelErrorMessage"/> and
<function>PQcancelSocket</function> itself).
</para>
</listitem>
</varlistentry>
<varlistentry id="libpq-PQcancelErrorMessage">
<term>
<function>PQcancelErrorMessage</function><indexterm><primary>PQcancelErrorMessage</primary></indexterm>
<indexterm><primary>error message</primary><secondary>in <structname>PGcancelConn</structname></secondary></indexterm>
</term>
<listitem>
<para>
Returns the error message most recently generated by an
operation on the cancel connection.
<synopsis>
char *PQcancelErrorMessage(const PGcancelConn *cancelconn);
</synopsis>
</para>
<para>
Nearly all <application>libpq</application> functions that take a
<structname>PGcancelConn</structname> will set a message for
<xref linkend="libpq-PQcancelErrorMessage"/> if they fail.
Note that by <application>libpq</application> convention,
a nonempty <xref linkend="libpq-PQcancelErrorMessage"/> result
can consist of multiple lines, and will include a trailing newline.
The caller should not free the result directly.
It will be freed when the associated
<structname>PGcancelConn</structname> handle is passed to
<xref linkend="libpq-PQcancelFinish"/>. The result string should not be
expected to remain the same across operations on the
<literal>PGcancelConn</literal> structure.
</para>
</listitem>