Skip to Content.
Sympa Menu

freetds - [freetds] Re: re RE: Newbie Q - Simple Socket Handshake?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: TDS Development Group <freetds AT lists.ibiblio.org>
  • Cc: "Craft, Steve" <SCraft AT LegionInsurance.com>
  • Subject: [freetds] Re: re RE: Newbie Q - Simple Socket Handshake?
  • Date: Wed, 22 Jan 2003 22:47:44 -0500

[forwarding message to the list from freetds-admin]
On Thu, 16 Jan 2003 14:13:20 -0500, "Craft, Steve"
<SCraft AT LegionInsurance.com> wrote:
> I created a simple program that determines the "up-state" of a MSSQL
> host by resolving the IP number, making a TCP connection to a port
> (default 1433), and writing to the console success/failure.
>
> But I don't think it's enough for the client to just check if there is a
> listener at 1433. To be more complete, I think it would make more sense
> to pass a command like "select getdate()" (after authentication). I
> think that would give a better picture of "up-state".
>
> With SMTP, I would
...
>
> I am guessing (famous last words) that TDS operates the same way(?)
> make a socket connection
> wait for some "hello bytes"
> send username/password
> wait for a "correct" response
> send some SQL to the box
> see if the result is what I want, show it on the console.
>
> So src/dblib/unittests/t0001.c has that kind of text?

Yes, the unit test provides a pretty good template. If you set TDSDUMP,
run the program, and examine the log, you'll get a pretty clear notion of
what's passed back and forth.

Compared to smtp, TDS is, well, let's just say it lacks the "s as in
simple". Simple it's not. I'd say it has more in common with tcp than
with smtp.

Your "guess" is about right, but the back-and-forth nature is a little
different because of the API's design. Here are the db-lib functions that
correspond to your description:

> make a socket connection
> wait for some "hello bytes"
[these two steps are implicit in dbopen()]
> send username/password
dblogin, dbsetluser (etc.), dbopen
> wait for a "correct" response
dbopen() blocks, returns a status.
> send some SQL to the box
dbcmd, dbsqlexec
> see if the result is what I want, show it on the console.
dbsqlexec() blocks, returns a status.
dbresults() indicates if the server returned data.

Reading results is considerably more complicated in TDS than smtp, because
the data are much richer. The library is instructed how & where to bind
each incoming value (dbbind), then results are read a row at a time
(dbnextrow).

Regards,

--jkl


> >>"I want to replicate, at the most basic level, the opening
> >transmission
> that a
> >>SQL Server service >makes. I am trying to create a simple "the server
> >is
> up"
> >>app, something beyond just connecting to the service port."
> >
> >If you want to "create a simple ... app" to test the presence of a
> >working server, you could look at src/dblib/unittests/t0001.c. It logs
> >in and exchanges data with the server.



  • [freetds] Re: re RE: Newbie Q - Simple Socket Handshake?, James K. Lowden, 01/22/2003

Archive powered by MHonArc 2.6.24.

Top of Page