Index: libs/libmythdb/msocketdevice_win.cpp
===================================================================
--- libs/libmythdb/msocketdevice_win.cpp	(revision 23062)
+++ libs/libmythdb/msocketdevice_win.cpp	(working copy)
@@ -306,6 +306,9 @@
 	case SendBuffer:
 	    n = SO_SNDBUF;
 	    break;
+	case Keepalive:
+	    n = SO_KEEPALIVE;
+	    break;
     }
     if ( n != -1 ) {
 	SOCKLEN_T len = sizeof(v);
@@ -361,6 +364,9 @@
 	case SendBuffer:
 	    n = SO_SNDBUF;
 	    break;
+	case Keepalive:
+	    n = SO_KEEPALIVE;
+	    break;
 	default:
 	    return;
     }
Index: libs/libmythdb/msocketdevice.cpp
===================================================================
--- libs/libmythdb/msocketdevice.cpp	(revision 23062)
+++ libs/libmythdb/msocketdevice.cpp	(working copy)
@@ -446,6 +446,27 @@
 
 
 /*!
+    Returns true if this socket has the keepalive option set.
+
+    \sa setKeepalive()
+*/
+bool MSocketDevice::keepalive() const
+{
+	return option( Keepalive );
+}
+
+/*!
+    Sets the keepalive option for this socket.
+
+    \sa keepalive()
+*/
+void MSocketDevice::setKeepalive( bool enable )
+{
+    setOption( Keepalive, enable );
+}
+
+
+/*!
     Returns the size of the operating system receive buffer.
 
     \sa setReceiveBufferSize()
Index: libs/libmythdb/msocketdevice_unix.cpp
===================================================================
--- libs/libmythdb/msocketdevice_unix.cpp	(revision 23062)
+++ libs/libmythdb/msocketdevice_unix.cpp	(working copy)
@@ -303,6 +303,9 @@
     case SendBuffer:
 	n = SO_SNDBUF;
 	break;
+    case Keepalive:
+	n = SO_KEEPALIVE;
+	break;
     }
     if ( n != -1 ) {
 	QT_SOCKOPTLEN_T len;
@@ -352,6 +355,9 @@
     case SendBuffer:
 	n = SO_SNDBUF;
 	break;
+    case Keepalive:
+	n = SO_KEEPALIVE;
+	break;
     default:
 	return;
     }
Index: libs/libmythdb/mythsocket.cpp
===================================================================
--- libs/libmythdb/mythsocket.cpp	(revision 23062)
+++ libs/libmythdb/mythsocket.cpp	(working copy)
@@ -41,6 +41,7 @@
     if (socket > -1)
     {
         setSocket(socket);
+        setKeepalive(true);
 #ifdef USING_MINGW
         // Windows sockets' default buffersize is too small for streaming
         // Could this apply to other platforms, too?
@@ -696,6 +697,7 @@
 
     setReceiveBufferSize(kSocketBufferSize);
     setAddressReusable(true);
+    setKeepalive(true);
     if (state() == Connecting)
     {
         setState(Connected);
Index: libs/libmythdb/msocketdevice.h
===================================================================
--- libs/libmythdb/msocketdevice.h	(revision 23062)
+++ libs/libmythdb/msocketdevice.h	(working copy)
@@ -94,6 +94,9 @@
     int		 sendBufferSize() const;
     virtual void setSendBufferSize( uint );
 
+    bool	 keepalive() const;
+    virtual void setKeepalive( bool );
+
     virtual bool connect( const QHostAddress &, quint16 );
 
     virtual bool bind( const QHostAddress &, quint16 );
@@ -146,7 +149,7 @@
     MSocketDevice::Error e;
     MSocketDevicePrivate * d;
 
-    enum Option { Broadcast, ReceiveBuffer, ReuseAddress, SendBuffer };
+    enum Option { Broadcast, ReceiveBuffer, ReuseAddress, SendBuffer, Keepalive };
 
     int		 option( Option ) const;
     virtual void setOption( Option, int );
