You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2004/09/15 22:32:21 UTC

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params HttpConnectionParams.java

olegk       2004/09/15 13:32:21

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpConnection.java
               httpclient/src/java/org/apache/commons/httpclient/params
                        HttpConnectionParams.java
  Log:
  PR #30652 (Allow configuration of SO_LINGER)
  
  Contributed by Oleg Kalnichevski
  Reviewed by Michael Becke
  
  Revision  Changes    Path
  1.100     +10 -4     jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java
  
  Index: HttpConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v
  retrieving revision 1.99
  retrieving revision 1.100
  diff -u -r1.99 -r1.100
  --- HttpConnection.java	13 Sep 2004 16:25:19 -0000	1.99
  +++ HttpConnection.java	15 Sep 2004 20:32:21 -0000	1.100
  @@ -679,6 +679,12 @@
   
               socket.setTcpNoDelay(this.params.getTcpNoDelay());
               socket.setSoTimeout(this.params.getSoTimeout());
  +            
  +            int linger = this.params.getLinger();
  +            if (linger >= 0) {
  +                socket.setSoLinger(linger > 0, linger);
  +            }
  +            
               int sndBufSize = this.params.getSendBufferSize();
               if (sndBufSize >= 0) {
                   socket.setSendBufferSize(sndBufSize);
  
  
  
  1.6       +40 -4     jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionParams.java
  
  Index: HttpConnectionParams.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionParams.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HttpConnectionParams.java	13 May 2004 04:01:22 -0000	1.5
  +++ HttpConnectionParams.java	15 Sep 2004 20:32:21 -0000	1.6
  @@ -94,6 +94,18 @@
       public static final String SO_RCVBUF = "http.socket.receivebuffer"; 
   
       /**
  +     * Sets SO_LINGER with the specified linger time in seconds. The maximum timeout 
  +     * value is platform specific. Value <tt>0</tt> implies that the option is disabled.
  +     * Value <tt>-1</tt> implies that the JRE default is used. The setting only affects 
  +     * socket close.  
  +     * <p>
  +     * This parameter expects a value of type {@link Integer}.
  +     * </p>
  +     * @see java.net.SocketOptions#SO_LINGER
  +     */
  +    public static final String SO_LINGER = "http.socket.linger"; 
  +
  +    /**
        * Determines the timeout until a connection is etablished. A value of zero 
        * means the timeout is not used. The default value is zero.
        * <p>
  @@ -219,6 +231,30 @@
        */
       public void setReceiveBufferSize(int size) {
           setIntParameter(SO_RCVBUF, size);
  +    }
  +
  +    /**
  +     * Returns linger-on-close timeout. Value <tt>0</tt> implies that the option is 
  +     * disabled. Value <tt>-1</tt> implies that the JRE default is used.
  +     * 
  +     * @return the linger-on-close timeout
  +     */
  +    public int getLinger() {
  +        return getIntParameter(SO_LINGER, -1);
  +    }
  +
  +    /**
  +     * Returns linger-on-close timeout. This option disables/enables immediate return 
  +     * from a close() of a TCP Socket. Enabling this option with a non-zero Integer 
  +     * timeout means that a close() will block pending the transmission and 
  +     * acknowledgement of all data written to the peer, at which point the socket is 
  +     * closed gracefully. Value <tt>0</tt> implies that the option is 
  +     * disabled. Value <tt>-1</tt> implies that the JRE default is used.
  +     *
  +     * @param value the linger-on-close timeout
  +     */
  +    public void setLinger(int value) {
  +        setIntParameter(SO_LINGER, value);
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org