freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Re: [freetds] Issue connecting to SQL Server from Linux Host with newerversions of FreeTDS...
- From: "Lowden, James K" <james.k.lowden AT alliancebernstein.com>
- To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] Issue connecting to SQL Server from Linux Host with newerversions of FreeTDS...
- Date: Mon, 27 Nov 2006 18:29:41 -0500
> From: Glenn, Chris
> Sent: Monday, November 27, 2006 9:06 AM
>
> I'm having an issue to connecting from a Red Hat Linux host to a
> SQL Server. I have older copies of FreeTDS that can connect (the
> 'newest' that I have that works is the freetds-0.65.dev.20060224
> build). I have been downloading and trying nightly builds since
> October without any success.
> ...
> net.c:184:Connecting to 10.3.2.40 port 1433 (TDS version 7.0)
> net.c:257:tds_open_socket: 10.3.2.40:1433: Invalid argument
Just last night I was reviewing our networking code in conjunction with
reading Steven's book, and it so happens I was looking at that very
function.
EINVAL is not a nice error code; it says we're not supplying a good
value for some element of the sockaddr_in structure. NetBSD's manpage
doesn't even mention it at as valid errno value for connect(2).
The code itself looks OK, and comparing it to revision 1.14 (Tue Feb 22
16:04:36 2005), most of the changes are to the logging code and adding
support for DOS32. That makes me wonder if it's a matter of configure
perhaps misdetecting your system somehow. I think it was around that
time that we upgraded the toolset that generates the configure script.
I added yet more logging code, cf. patch below. With it, your log file
should now dump the sockaddr_in structure. You can verify that, say,
sin_family really is AF_INET according to your system's header files.
I'm not sure we should leave this code in; it won't compile under Win32,
for instance. But it will be in the next snapshot, and maybe it will
help solve your problem.
--jkl
== snip ==
Index: src/tds/net.c
===================================================================
RCS file: /cvsroot/freetds/freetds/src/tds/net.c,v
retrieving revision 1.46
diff -u -r1.46 net.c
--- src/tds/net.c 26 Nov 2006 21:00:54 -0000 1.46
+++ src/tds/net.c 27 Nov 2006 22:51:34 -0000
@@ -235,6 +235,23 @@
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, "error: connect(2) returned
0x%x, \"%s\"\n", sock_errno, strerror(sock_errno));
+ if (sock_errno != ECONNREFUSED && sock_errno !=
ENETUNREACH) {
+ tdsdump_dump_buf(TDS_DBG_ERROR, "Contents of
sockaddr_in", &sin, sizeof(sin));
+ tdsdump_log(TDS_DBG_ERROR, "
sockaddr_in:\t"
+ "%s =
%x\n"
+ "\t\t\t%s =
%x\n"
+ "\t\t\t%s =
%x\n"
+ "\t\t\t%s =
%x\n"
+ "\t\t\t%s =
'%s'\n"
+ , "sin_len",
sin.sin_len
+ , "sin_family",
sin.sin_family
+ , "sin_port",
sin.sin_port
+ ,
"sin_addr.s_addr", sin.sin_addr.s_addr
+ , "(param
ip_addr)", ip_addr
+ );
+ }
}
if (retval < 0 && sock_errno == TDSSOCK_EINPROGRESS)
retval = 0;
== snip ==
-----------------------------------------
The information contained in this transmission may be privileged and
confidential and is intended only for the use of the person(s) named
above. If you are not the intended recipient, or an employee or agent
responsible
for delivering this message to the intended recipient, any review,
dissemination,
distribution or duplication of this communication is strictly prohibited. If
you are
not the intended recipient, please contact the sender immediately by reply
and destroy all copies of the original message. Please note that we do not
accept
account orders and/or instructions by e-mail, and therefore will not be
responsible
for carrying out such orders and/or instructions. If you, as the intended
recipient
of this message, the purpose of which is to inform and update our clients,
prospects
and consultants of developments relating to our services and products, would
not
like to receive further e-mail correspondence from the sender, please "reply"
to the
sender indicating your wishes. In the U.S.: 1345 Avenue of the Americas, New
York,
NY 10105.
- Re: [freetds] Issue connecting to SQL Server from Linux Host with newerversions of FreeTDS..., Lowden, James K, 11/27/2006
Archive powered by MHonArc 2.6.24.