/*
* call-seq:
* conn.connect_poll() -> Fixnum
*
* Returns one of:
* * +PGRES_POLLING_READING+ - wait until the socket is ready to read
* * +PGRES_POLLING_WRITING+ - wait until the socket is ready to write
* * +PGRES_POLLING_FAILED+ - the asynchronous connection has failed
* * +PGRES_POLLING_OK+ - the asynchronous connection is ready
*
* Example:
* conn = PGconn.connect_start("dbname=mydatabase")
* socket = IO.for_fd(conn.socket)
* status = conn.connect_poll
* while(status != PGconn::PGRES_POLLING_OK) do
* # do some work while waiting for the connection to complete
* if(status == PGconn::PGRES_POLLING_READING)
* if(not select([socket], [], [], 10.0))
* raise "Asynchronous connection timed out!"
* end
* elsif(status == PGconn::PGRES_POLLING_WRITING)
* if(not select([], [socket], [], 10.0))
* raise "Asynchronous connection timed out!"
* end
* end
* status = conn.connect_poll
* end
* # now conn.status == CONNECTION_OK, and connection
* # is ready.
*/
static VALUE
pgconn_connect_poll(VALUE self)
{
PostgresPollingStatusType status;
status = PQconnectPoll(get_pgconn(self));
return INT2FIX((int)status);
}