Li, Robert writes: > Hi, > I am a programmer. Now i want to know how to know > whether MySQL server is down or not through C API. > For me, i know if we use mysql_real_connect() to > connect MySQL server, when error returns we can not > distinguish it's due to authentation error or mysql server down. > Can we use mysql_error() after mysql_real_connect? > But what's the error code for mysql server down or > authentation error. > Thanks and regards. > Robert Li > Computer Associates > Programmer, R&D Beijing (China) > tel: +86 10 65611136 ext 852 > fax: +86 10 85298979 > [EMAIL PROTECTED] >
Hi! You can try using our C API function mysql_ping(). Here is a description: int mysql_ping(MYSQL *mysql)' Description ........... Checks whether or not the connection to the server is working. If it has gone down, an automatic reconnection is attempted. This function can be used by clients that remain idle for a long while, to check whether or not the server has closed the connection and reconnect if necessary. Return Values ............. Zero if the server is alive. Non-zero if an error occurred. Errors ...... `CR_COMMANDS_OUT_OF_SYNC' Commands were executed in an improper order. `CR_SERVER_GONE_ERROR' The *MySQL* server has gone away. `CR_UNKNOWN_ERROR' An unknown error occurred. Would you be so nice to tell us what is Computer Associates of China using MySQL for ?? -- Regards, __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic <[EMAIL PROTECTED]> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, FullTime Developer /_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus <___/ www.mysql.com --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php