Hello.
In my opinion it depends on the value of reconnect flag (the part of
MYSQL structure). I've written a simple program which connects to MySQL
server,
waits a bit and executes mysql_ping. While it is waiting, MySQL server
is being restarted. If mysql.reconnect = 1, mysql_ping() returns
success, otherwise we have "Server has gone away". Here is the test program:
#include<stdio.h>
#include<mysql/mysql.h>
int main()
{
MYSQL mysql;
char c;
printf("Begin\n");
mysql_init(&mysql);
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"mysql");
if (!mysql_real_connect(&mysql,"localhost"
,"root"
,""
,"test"
,0
,NULL
,0))
{
fprintf(stderr, "Failed to connect to database: Error: %s\n",
mysql_error(&mysql));
}
mysql.reconnect = 0;
c=getchar();
if( mysql_ping(&mysql) != 0)
{
printf("Error: %s", mysql_error(&mysql));
}
else
{
printf("Ok!\n");
}
}
Lefteris Tsintjelis wrote:
> Hi,
>
> Is mysql_ping () suppose to restore a db connection even after a db
> restart?
>
> Thnx,
>
> Lefteris
>
--
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]