//gcc testcase.c -Wall -g -o testcase -L/home/sbester/mysql/5.1/mysql-advanced-gpl-5.1.51-linux-x86_64-glibc23/lib -I/home/sbester/mysql/5.1/mysql-advanced-gpl-5.1.51-linux-x86_64-glibc23/include -lmysqlclient_r -lz -lm -lpthread #include #include #include #include #include #include #include char host[]="127.0.0.1"; int port=3333; //make sure this is not running anything. i.e. connection must fail! char username[]="root"; char password[]=""; int main(int argc, const char *argv[]) { MYSQL *dbc=NULL; int i=0; for(i=0;i<1000;i++) { if (!(dbc=mysql_init(NULL))) { printf("mysql_init failed\n"); goto threadexit; } else { if (!mysql_real_connect(dbc,host,username,password,NULL,port, NULL, CLIENT_FOUND_ROWS|CLIENT_MULTI_STATEMENTS|CLIENT_MULTI_RESULTS)) { printf("mysql_real_connect failed: %s (%d) (%s)", mysql_error(dbc),mysql_errno(dbc),mysql_sqlstate(dbc)); /* uncomment this line to prevent a memory leak: */ // mysql_close(dbc); } else { mysql_close(dbc); } } } mysql_library_end(); exit(0); threadexit: exit(-1); }