Pavel Golub wrote:
> Hello, postgresmen.
> I found solution how to implement keep alive through sockets in
> archive: http://archives.postgresql.org/pgsql-interfaces/2006-11/msg00014.php
> However, it is dated 2006 year and I am wonder if this is for real?
setsockopt has been around since at least the early 90s. It is for real.
> At least in Windows environment?
> If not are there any solutions?
Use WSAIoctl(SIO_KEEPALIVE_VALS). SIO_KEEPALIVE_VALS is supported on
Windows 2000 and later.
Search the page for "SIO_KEEPALIVE_VALS".
Make sure to test the below because I didn't :)
#include <Mstcpip.h> /* struct tcp_keepalive */
struct tcp_keepalive ka;
/* enable or disable (same as SO_KEEPALIVE) */
ka.onoff = 1;
/* milliseconds (same as TCP_KEEPIDLE) */
ka.keepalivetime = 60000;
/* milliseconds (same as TCP_KEEPINTVL) */
ka.keepaliveinterval = 3000;
/* configure keep-alives for 'conn' */
r = WSAIoctl((SOCKET) PQsocket(conn), SIO_KEEPALIVE_VALS,
&ka, (DWORD) sizeof(ka), NULL, 0, &dw, NULL, NULL);
if (r == SOCKET_ERROR)
// failed, check WSAGetLastError()
Apparently, you can also enable keep-alives using the standard
setsockopt(...SO_KEEPALIVE...); Although, the other knobs are only
exposed through WSAIoctl. When using SO_KEEPALIVE, the default
keep-alive settings are used ... keep-alive timeout of 2 hours followed
by a 1 second probe. They can still be adjusted via WSAIoctl.
every bit counts
In response to
pgsql-hackers by date
|Next:||From: Peter Eisentraut||Date: 2009-05-27 13:33:28|
|Subject: Re: PostgreSQL Developer meeting minutes up|
|Previous:||From: Bruce Momjian||Date: 2009-05-27 13:16:18|
|Subject: Re: A couple of gripes about the gettext plurals