I'm new to programming, so bear with me. Also using GNU/Linux.
So I'm trying to create a loop that will check if I have used CTRL+D to end the loop to a MySQL connection, but at the same time constantly check the connection to the server.
while ((c = getchar()) != EOF)
{
if (mysql_ping(conn) == 1)
{
fprintf(stderr, "Error: %s\n", mysql_error(conn));
}
}
A problem is that I constantly have to press ENTER to check if the connection is still alive, however I want it to automatically check the connection to the MySQL server while still having the EOF feature so people can close the connection.
I know why this is happening, I'm just not sure how to fix it. Are there any other inbuilt functions or possible external libraries that I require?