dbpoll

Description

Verifies that a server response has arrived for a DBPROCESS.

Syntax

RETCODE dbpoll(dbproc, milliseconds, ready_dbproc, 
             return_reason)
 
DBPROCESS     *dbproc;
long                     milliseconds;
DBPROCESS    **ready_dbproc;
int                        *return_reason;

Parameters

dbproc

A pointer to the DBPROCESS structure that provides the connection for a particular front-end/server process. It contains all the information that DB-Library/C uses to manage communications and data between the front end and server.

dbproc represents the DBPROCESS connection that dbpoll will check.

If dbproc is passed as NULL, dbpoll will check all open DBPROCESS connections to see if a response has arrived for any of them.

milliseconds

The maximum number of milliseconds that dbpoll should wait for a response before returning.

If milliseconds is passed as 0, dbpoll returns immediately.

If milliseconds is passed as -1, dbpoll will not return until either a server response arrives or a system interrupt occurs.

ready_dbproc

A pointer to a pointer to a DBPROCESS structure. dbpoll sets *ready_dbproc to point to the DBPROCESS for which the server response has arrived. If no response has arrived, dbpoll sets *ready_dbproc to NULL.

Noteready_dbproc is not a DBPROCESS pointer. It is a pointer to a DBPROCESS pointer.

return_reason

A pointer to an integer representing the reason dbpoll has returned. The integer will be one of the following symbolic values:

DBRESULT

A response to a server command has arrived. The application may call dbsqlok (assuming that dbsqlsend has been called) to examine the server’s response.

DBNOTIFICATION

A registered procedure notification has arrived. If a handler for this registered procedure has been installed using dbreghandle, dbpoll invokes this handler before it returns. If a handler for the registered procedure has not been installed and there is no default handler installed for this DBPROCESS, DB-Library raises an error when it reads the notification.

DBTIMEOUT

The time indicated by the milliseconds parameter elapsed before any server response arrived.

DBINTERRUPT

An operating-system interrupt occurred before any server response arrived and before the timeout period elapsed.

NoteThis list may expand in the future, as more kinds of server responses are recognized by DB-Library/C. It is recommended that application programs be coded to handle unexpected values in return_reason without error.

Returns

SUCCEED or FAIL.

dbpoll returns FAIL if any of the server connections it checks has died. If dbpoll returns FAIL, ready_dbproc and return_reason are undefined.

Usage


Using dbpoll for non-blocking reads


Using dbpoll for registered procedure notifications

See also

DBIORDESC, DBRBUF, dbresults, dbreghandle, dbsqlok