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: [email protected] For additional commands, e-mail: [email protected]
