commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwins...@apache.org
Subject svn commit: r749145 - /commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java
Date Sun, 01 Mar 2009 22:43:01 GMT
Author: rwinston
Date: Sun Mar  1 22:43:01 2009
New Revision: 749145

URL: http://svn.apache.org/viewvc?rev=749145&view=rev
Log:
Add SO_KEEPALIVE for completeness

Modified:
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java?rev=749145&r1=749144&r2=749145&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java
Sun Mar  1 22:43:01 2009
@@ -436,8 +436,31 @@
     {
         return _socket_.getTcpNoDelay();
     }
-
-
+    
+    /**
+     * Sets the SO_KEEPALIVE flag on the currently opened socket.
+     * 
+     * From the Javadocs, the default keepalive time is 2 hours (although this is 
+     * implementation  dependent). It looks as though the Windows WSA sockets implementation
+     * allows a specific keepalive value to be set, although this seems not to be the case
on 
+     * other systems.
+     * @param  keepAlive If true, keepAlive is turned on
+     * @throws SocketException
+     */
+    public void setKeepAlive(boolean keepAlive) throws SocketException {
+    	_socket_.setKeepAlive(keepAlive);
+    }
+    
+    /**
+     * Returns the current value of the SO_KEEPALIVE flag on the currently opened socket.
+     * 
+     * @return True if SO_KEEPALIVE is enabled.
+     * @throws SocketException
+     */
+    public boolean getKeepAlive() throws SocketException {
+    	return _socket_.getKeepAlive();
+    }
+    
     /**
      * Sets the SO_LINGER timeout on the currently opened socket.
      * <p>



Mime
View raw message