Skip to Content.
Sympa Menu

freetds - Re: [freetds] PHP 5.2.6 + pdo_dblib + FreeTDS 0.64 -- tds_open_socket: Unknown error: 0

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] PHP 5.2.6 + pdo_dblib + FreeTDS 0.64 -- tds_open_socket: Unknown error: 0
  • Date: Thu, 24 Jul 2008 14:23:12 -0400

Kian Mohageri wrote:
> 19:27:18.240697 12864 (net.c:210):Connecting to 140.160.12.123 port
> 2638 (TDS version 5.0)
> 19:27:18.240926 12864 (net.c:264):tds_open_socket: connect(2) returned
> "Unknown error: 0"

I can tell you what's happening, but not why. I suspect it's some kind of
local network setup problem, perhaps a firewall or permissions.

Here's the relevant code from src/tds/net.c:


retval = connect(tds->s,
(struct sockaddr *) &sin,
sizeof(sin));
if (retval == 0) {
tdsdump_log(TDS_DBG_INFO2,
"connection established\n");
} else {
tdsdump_log(TDS_DBG_ERROR,
"tds_open_socket: connect(2) returned \"%s\"\n",

strerror(sock_errno));
...

http://www.opengroup.org/onlinepubs/000095399/functions/connect.html

connect(2) may return only 0 or -1, and should set errno. It appears to
be returning nonzero, but not setting errno. (sock_errno is just errno
except on Win32.) That is, it reports failure but not why.

The only conclusion I can draw is that your FreeTDS configuration is
correct, but something is amiss with your network setup that prevents your
PHP application from forming the connection. Moreover, IMO you have a
FreeBSD bug, because a non-zero return code from connect(2) must be
accompanied by a valid errno value.

HTH. :-/

--jkl






Archive powered by MHonArc 2.6.24.

Top of Page