I agree it's solve my problem but can give a bigger one.
The problem is I can't succeed to prevent opening a lot of connection

On Tue, Dec 22, 2009 at 1:51 PM, Jaakko <rosvopaalli...@gmail.com> wrote:

> Hi,
>
> I don't know the particulars of java implementation, but if it works
> the same way as Unix native socket API, then I would not recommend
> setting linger to zero.
>
> SO_LINGER option with zero value will cause TCP connection to be
> aborted immediately as soon as the socket is closed. That is, (1)
> remaining data in the send buffer will be discarded, (2) no proper
> disconnect handshake and (3) receiving end will get TCP reset.
>
> Sure this will avoid TIME_WAIT state, but TIME_WAIT is our friend and
> is there to avoid packets from old connection being delivered to new
> incarnation of the connection. Instead of avoiding the state, the
> application should be changed so that TIME_WAIT will not be a problem.
> How many open files you can see when the exception happens? Might be
> that you're out of file descriptors.
>
> -Jaakko
>
>
> On Tue, Dec 22, 2009 at 8:17 PM, Richard Grossman <richie...@gmail.com>
> wrote:
> > Hi
> > To all is interesting I've found a solution seems not recommended but
> > working.
> > When opening a Socket set this:
> >    tSocket.getSocket().setReuseAddress(true);
> >    tSocket.getSocket().setSoLinger(true, 0);
> > it's prevent to have a lot of connection TIME_WAIT state but not
> > recommended.
> >
>

Reply via email to