Recent

Author Topic: mysql_connect() fails with error Can't create TCP/IP socket  (Read 8505 times)

Boromir

  • Newbie
  • Posts: 2
mysql_connect() fails with error Can't create TCP/IP socket
« on: November 21, 2005, 06:32:17 pm »
Hi,
I try to connect to a MySQL-Server that runs on localhost:3306.
With java and MySQL-connector this works fine.
Now I want to do that with fpc.
I used the tutorial on the wiki
http://wiki.lazarus.freepascal.org/index.php/Lazarus_Database_Tutorial#Lazarus_and_MySQL

This is my function:

//uses MySQL3   just for info

Code: [Select]

function fConnect(const Host, User, Passwd: PChar) : boolean;
var mysql : TMYSQL;
    alloc, sock : PMYSQL;
    res : boolean;
begin
     res := true;
     alloc := mysql_init(@mysql);
     write('Connecting to MySQL... ');
     //sock := mysql_connect(alloc, host, user, Passwd);
     sock := mysql_real_connect(alloc, host, user, Passwd, 0, nil, 0);
     if assigned(sock) THEN
     begin
          Writeln('done');
          Writeln('Connection data:');
          Writeln ('Host info       : ',mysql_get_host_info(sock));
          Writeln ('Server info     : ',mysql_stat(sock));
          Writeln ('Client info     : ',mysql_get_client_info);
     end
     else
     begin
          res := false;
          writeln('failed');
          writeln(stderr, mysql_error(@mysql));
     end;
     
     fConnect := res;
end;

But I get following error message:
Can't create TCP/IP socket (10106)

Version of MySQL 3.23 (but I'm currently downloading 4.1)

So what am I doing wrong, or is it a bug?


Regards
  Fabian

Boromir

  • Newbie
  • Posts: 2
RE: mysql_connect() fails with error Can
« Reply #1 on: November 21, 2005, 11:38:41 pm »
Solved.
Previously the MySQL-Server-Deamon was mysqld.exe
but it has to be mysqld-nt.exe

That's it.

Connecting to a MySQL-Server on Linux which runs on another Computer works, too.

Bye.

 

TinyPortal © 2005-2018