You are here : cpp0mysql_ping

mysql_ping() - 0

 Checks whether the connection to the server is working. If the
        connection has gone down and auto-reconnect is enabled an
        attempt to reconnect is made. If the connection is down and
        auto-reconnect is disabled,
        mysql_ping() returns an error.mysql_ping()mysql_ping()Auto-reconnect is disabled by default. To enable it, call
        mysql_options() with the
        MYSQL_OPT_RECONNECT option. For details, see
        Section 25.8.7.50, “mysql_options()”.mysql_options()mysql_options()MYSQL_OPT_RECONNECTSection 25.8.7.50, “mysql_options()”mysql_ping() can be used by
        clients that remain idle for a long while, to check whether the
        server has closed the connection and reconnect if necessary.mysql_ping()mysql_ping()If mysql_ping()) does cause a
        reconnect, there is no explicit indication of it. To determine
        whether a reconnect occurs, call
        mysql_thread_id() to get the
        original connection identifier before calling
        mysql_ping(), then call
        mysql_thread_id() again to see
        whether the identifier has changed.mysql_ping()mysql_ping()mysql_thread_id()mysql_thread_id()mysql_ping()mysql_ping()mysql_thread_id()mysql_thread_id()If reconnect occurs, some characteristics of the connection will
        have been reset. For details about these characteristics, see
        Section 25.8.16, “Controlling Automatic Reconnection Behavior”.Section 25.8.16, “Controlling Automatic Reconnection Behavior”


Syntax

int mysql_ping(MYSQL *mysql)


Example

 


Output / Return Value

 Zero if the connection to the server is active. Nonzero if an
        error occurred. A nonzero return does not indicate whether the
        MySQL server itself is down; the connection might be broken for
        other reasons such as network problems.


Limitations


Alternatives / See Also


Reference