in reply to IO::Socket persisting on Linux despite being closed (updated)

Linux keeps the socket in use while it is in the TIME_WAIT state. The SO_REUSEADDR option may help.

I haven't tried but does the following work?

$socket->setsockopt( SOL_SOCKET, SO_REUSEADDR, 1 );

Update: IO::Socket::INET references SO_REUSEADDR and SO_REUSEPORT. You may need to try each.

Replies are listed 'Best First'.
Re^2: IO::Socket persisting on Linux despite being closed
by Anonymous Monk on Oct 25, 2018 at 20:16 UTC
    SO_REUSEPORT is Linux-specific option to facilitate multi-threaded servers:
    SO_REUSEPORT (since Linux 3.9)
    Permits multiple AF_INET or AF_INET6 sockets to be bound to an identical socket address.
    For TCP sockets, this option allows accept(2) load distribution in a multi-threaded server to be improved by using a distinct listener socket for each thread. This provides improved load distribution as compared to traditional techniques such using a single accept(2)ing thread that distributes connections, or having multiple threads that compete to accept(2) from the same socket.
    Probably shouldn't be relevant here.