[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpclient-users
Subject:    Re: SO_LINGER option
From:       Oleg Kalnichevski <olegk () apache ! org>
Date:       2011-02-11 13:56:27
Message-ID: 1297432587.9641.4.camel () ubuntu
[Download RAW message or body]

On Fri, 2011-02-11 at 11:48 +0100, Kennke, Roman wrote:
> Hello,
> 
> I see it is possible to set the SO_LINGER option by calling
> 
> HttpConnectionParams.setLinger(params, so_linger);
> 
> However, from looking at the docs and specification I find that it is not possible \
> to enable SO_LINGER and set it to 0 at the same time. This should force immediate \
> shutdown of a socket upon close(), according to the spec in java.net.SocketOptions. \
> But HttpClient treats 0 as disabled linger. As far as I understand, disabled linger \
> is different from enabled linger with 0. How can I enable linger with a timeout of \
> 0? 
> For more info consider:
> http://developerweb.net/viewtopic.php?id=2982
> 
> The implementation in HttpClient is in the class \
> DefaultHttpClientConnection.bind(): 
> 
> int linger = HttpConnectionParams.getLinger(params);
> if (linger >= 0) {
> socket.setSoLinger(linger > 0, linger);
> 
> 
> }
> 

Roman

In this particular case (SO_LINGER=0) the socket parameter has a special
semantic and therefore it should be treated differently.

Instead of using parameters, you should override HttpConnection#shutdown
method and implement whatever extra logic you deem appropriate for your
application.

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic