Skip to Content.
Sympa Menu

freetds - Re: [freetds] Connection life

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Connection life
  • Date: Thu, 24 Nov 2005 09:03:02 +0100

>
> Hello, I have a question about connection and disconnection.
> How can I
> detect if a network connection is dead using db-lib? I have
> seen that there
> is a function called dbdead, but this function does not
> check if the
> network socket is alive ( I use MS Sql Server), it never
> connects to the
> server... I need this because I have a connection pooling and
> I havte to
> detect connections dead to reconnect if it is needed, I keep
> the connection
> without calling a dbclose for a long time. But if the dbdead
> does not check
> the socket the result of calling dbdead is not reliable.
> How can I solve this problem?
>
> Thanks...
>

I don't know if even tcp support this. Current version use keep alive in
socket but I don't know if there is a way to read error like using
select on error with timeout == 0 or use recv with zero bytes or reading
error with getsockopt/SO_ERROR...
However I would suggest to close connections if they are idle for a long
time (some minutes), closing unused connection can free memory on mssql
side and prevent potential locks.

freddy77




Archive powered by MHonArc 2.6.24.

Top of Page