Re: SIGHUP on connect

From: Michael J. Baars
Date: Thu Oct 29 2020 - 11:20:31 EST


Hi Bernd,

According to manual page socket(7), SO_REUSEADDR allows for local addresses to be reused for binding. I've tested this socket option with the WAN address, it
appears the problem is solved for both local and non-local connections.

I also found the the SO_LINGER socket option to be useful in some way. By default, SO_LINGER is set to 0, so you would think that lingering connections were out
of the question. However, an enabled linger with a l_onoff = 1 and a l_linger = 0 seems to work a lot better than a disabled linger with a l_onoff = 0 and a
l_linger = 0.

Which option would you use?

Mischa.

On Mon, 2020-10-26 at 17:12 +0000, Bernd Petrovitsch wrote:
> Hi all!
>
> On 25/10/2020 16:11, Michael J. Baars wrote:
> [...]
> > I've been writing a simple client and server for cluster computing this weekend. At first everything appeared to work just fine, but soon enough I found
> > some
> > inexplicable bind errors. I've tried to make sure that the client closes it's sockets before the server closes it's sockets, to prevent linger, but trying
> > did
>
> Which were exactly?
> English/original text pls ...
>
> And The close() (and shutdown() syscalls, respectively) don't avoid
> the FIN_WAIT2 timeout on a closed socket.
> Just set the SO_REUSEADDR socket option on the listening socket.
>
> > not help. Now I think I found the problem.
>
> Then solve it.
>
> > Please do have a look at the code. It looks like the SIGHUP is sent to the server not on close or exit, but on the connect instead.
>
> Too lazy to save and uncompress the file ...
>
> MfG,
> Bernd

Attachment: so_reuseaddr and so_linger.tar.xz
Description: application/xz-compressed-tar