freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "martin A." <acevedoma AT hotmail.com>
- To: freetds AT lists.ibiblio.org
- Subject: Re: [freetds] Connection life
- Date: Fri, 25 Nov 2005 18:00:34 +0000
Hello, thank you for your help, I will try to put some expiration time in minutes, after that I consider the conecction is dead, I do not know very much about sockets and tcp programming...
From: "Pickett, David" <David.Pickett AT phlx.com>
Reply-To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
To: 'FreeTDS Development Group' <freetds AT lists.ibiblio.org>
Subject: Re: [freetds] Connection life
Date: Fri, 25 Nov 2005 10:22:51 -0500
TCP will send a FIN packet if the remote end closes a socket. Keepalive, if
turned on and not subverted by router traffic reduction faking, will
eventually time out for 100% packet loss. Either will raise an error or EOF
condition that read(), write(), poll(), if configured to accept all events,
and probably select() (I know poll better, but they are generally
equivalent) will notice on the local socket fd. I am not sure if the remote
close comes up as an error event, a read event or a write event, but it
comes up.
Similar things happen with pipes. Generally, you cannot check to see if a
remote pipe reader has closed by sending a zero length message, as most
readers take this as EOF (read() returns zero). Maybe there is an out of
band message you can use that does not upset simple readers; I have tried to
live the simple life, without knowing much about the funny messages on a
stream.
At the TCP level, an empty message is an ack or keepalive message. (Both are
identical in content but different in triggering mechanism.) I am unsure if
it always produces an event. However, on the rumor of past woes, I have
coded some socket apps to declare EOF only for N consecutive read()=0
responses within a second (a real EOF will repeat N times relatively
immediately, but TCP ack/keepalive timers run at much longer intervals).
Nobody said it would be easy!
Of course, an up connection does not mean the server is viable -- it might
be hung and ignore activity on its sockets. You can only tell by requesting
some sort of service.
-----Original Message-----
From: ZIGLIO, Frediano, VF-IT [mailto:Frediano.Ziglio AT vodafone.com]
Sent: Thursday, November 24, 2005 3:03 AM
To: FreeTDS Development Group
Subject: Re: [freetds] Connection life
>
> 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
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
-
[freetds] Connection life,
martin A., 11/23/2005
- Re: [freetds] Connection life, Robert Klemme, 11/24/2005
- Re: [freetds] Connection life, James K. Lowden, 11/26/2005
- <Possible follow-up(s)>
- Re: [freetds] Connection life, ZIGLIO, Frediano, VF-IT, 11/24/2005
-
Re: [freetds] Connection life,
Pickett, David, 11/25/2005
- Re: [freetds] Connection life, martin A., 11/25/2005
- Re: [freetds] Connection life, Pickett, David, 11/27/2005
- Re: [freetds] Connection life, Pickett, David, 11/27/2005
Archive powered by MHonArc 2.6.24.