setnonblocking (PGconn)

    /*
     * call-seq:
     *    conn.setnonblocking(Boolean) -> nil
     *
     * Sets the nonblocking status of the connection.
     * In the blocking state, calls to PGconn#send_query
     * will block until the message is sent to the server,
     * but will not wait for the query results.
     * In the nonblocking state, calls to PGconn#send_query
     * will return an error if the socket is not ready for
     * writing.
     * Note: This function does not affect PGconn#exec, because
     * that function doesn't return until the server has
     * processed the query and returned the results.
     * Returns +nil+.
     */
    static VALUE
    pgconn_setnonblocking(self, state)
            VALUE self, state;
    {
            int arg;
            VALUE error;
            PGconn *conn = get_pgconn(self);
            if(state == Qtrue)
                    arg = 1;
            else if (state == Qfalse)
                    arg = 0;
            else
                    rb_raise(rb_eArgError, "Boolean value expected");

            if(PQsetnonblocking(conn, arg) == -1) {
                    error = rb_exc_new2(rb_ePGError, PQerrorMessage(conn));
                    rb_iv_set(error, "@connection", self);
                    rb_exc_raise(error);
            }
            return Qnil;
    }