Hello.
I've found that mysql_ping doesn't work properly with TCP connection (in your test case you put the hostname to "127.0.0.1"). My program was working with "localhost" - connection through the Unix socket. You may want to add you comments to my bug report at: http://bugs.mysql.com/bug.php?id=14057 Lefteris Tsintjelis wrote: > I did some extensive testing and it looks like that only the first > mysql_ping () fails to reconnect or very possibly returns the wrong > result. I am currently using v4.1.14. > > Regards, > > Lefteris > > ---------------------------------------------------- > Begin > MySQL is up and running > Restart MySQL and hit enter (reconnect: 1)... > > Error: Lost connection to MySQL server during query > Ping 2 Ok! > Ping 3 Ok! > ---------------------------------------------------- > #include <stdio.h> > #include <mysql.h> > > int main () > { > int i; > char c; > MYSQL mysql; > > fprintf (stdout, "Begin\n"); > mysql_init (&mysql); > if (!mysql_real_connect (&mysql, "127.0.0.1", "root", "", > "test", 0, NULL, 0)) > fprintf (stderr, "Failed to connect to database: Error: > %s\n", mysql_error (&mysql)); > else > fprintf (stdout, "MySQL is up and running\n"); > mysql.reconnect = 1; > fprintf (stdout, "Restart MySQL and hit enter (reconnect: > %d)...", mysql.reconnect); > c = getchar (); > (void) putc ('\n', stdout); > for (i = 1; i < 4; i++) > if (mysql_ping (&mysql)) > fprintf (stderr, "Error: %s\n", > mysql_error(&mysql)); > else > fprintf (stdout, "Ping %d Ok!\n", i); > return (0); > } > -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.NET http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Gleb Paharenko / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.NET <___/ www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]