List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:February 5 2000 8:25pm
Subject:Re: C API problem
View as plain text  
>Robert Gehrig wrote:
>>
>>  Hi
>>
>>  I am trying to get a small test client written in C to connect to 
>>my MySQL server.
>>
>>  I am compiling on OS/2 with emx
>>
>>  The end executable is called myclnt.exe
>>
>>  This what happens when I run the program
>>
>>  [E:\mysql2\client]myclnt
>>  Init worked
>>  Host: 216.161.180.210
>>  User: ginger
>>  Pwrd: ginger
>>    Db: desert_fox
>>                                                      <-- I 
>>terminated it with a control C
>>  Process terminated by SIGINT in thread 1
>>
>>  [E:\mysql2\client]
>>
>>  I have include my makefile and the source of my program in this e-mail.
>>
>>  Any ideas what I may be doing wrong.
>>
>>  If you need any more info about my setup just ask.
>>
>>  The make file is as follows:
>>  CC=gcc
>>  INCLUDES = -I\mysql2\include
>>  LIBS = -L\mysql2\lib
>>
>>  all: myclnt
>>
>>  client.o:      client.c
>>          $(CC) -c $(INCLUDES) client.c
>>
>>  myclnt: client.o
>>          $(CC) -O2 -o myclnt.exe client.o $(LIBS)  -lmysqlclient -lpthrdrtl
>>
>>  Here is my c code:
>>  /* Client1.c */
>>
>>  #include <stdio.h>
>>  #include <mysql.h>
>>
>>  MYSQL *conn;
>>
>>  int  main (int argc, char *argv[])
>>  {
>>    char *def_host_name = "216.161.180.210";
>>    char *def_user_name = "ginger";
>>    char *def_password  = "ginger";
>>    char *def_db_name   = "desert_fox";
>>
>>    conn = mysql_init(NULL);
>>
>>    if(conn != NULL)
>>      {
>>      printf("Init worked\n");
>>      printf("Host: %s\n", def_host_name);
>>      printf("User: %s\n", def_user_name);
>>      printf("Pwrd: %s\n", def_password);
>>      printf("  Db: %s\n", def_db_name);
>>
>>      if (mysql_real_connect (
>>                  conn,           /* pointer to connection handler */
>>                  def_host_name,  /* host to connect to            */
>>                  def_user_name,  /* user name                     */
>>                  def_password,   /* password                      */
>>                  def_db_name,    /* Database to connect to        */
>>                  3306,
>>                  NULL,
>>                  0) == NULL)     /* flags (none)                  */
>>        printf("Connect Failed\n Error: %u (%s)\n", 
>>mysql_errno(conn), mysql_error(conn));
>>
>>      mysql_close(conn);
>>      }
>>    exit(0);
>>  }
>>
>>  Thanks
>>
>>  Robert Gehrig
>>  Webmaster at www.gdbarri.com
>>
>>  e-mail: webmaster@stripped
>
>To really know what's going on, I would just trace it in gdb.
>
>However, I suspect that it hangs in mysql_real_connect because of either DNS
>problems or being unable to contact the server host on port 3306 ( 
>no response).
>
>Can you telnet to port 3306 from the client machine?
>
>--
>Sasha Pachev

A little more information on this one (Robert contacted me, but I don't
know enough about OS/2 to know what to suggest):

- The mysql.exe binary from his distribution can connect to the server okay.

- The program he's trying to compile and run does connect to the server,
   because if he runs mysqladmin, it shows the connection, in "unknown"
   state (or perhaps "login").  But the connection never successfully
   completes.

Perhaps some difference between his compiler, and the compiler used to
build the OS/2 binary distribution?  I dunno.

-- 
Paul DuBois, paul@stripped
Thread
C API problemRobert Gehrig5 Feb
  • Re: C API problemsasha5 Feb
    • Re: C API problemPaul DuBois5 Feb
  • Re: C API problemsinisa6 Feb