in reply to Re: Clean closing sockets
in thread Clean closing sockets

Okay, thats a fair enough answer. So my question is this, not to sound daft or anything:

How do I setockopt() on a SOCKET when I can't generate the SOCKET because it won't bind to the port I'm telling it to?
Clarify:

my $server = IO::Socket::INET->new(....); setsockopt($server, SOL_SOCKET, SO_REUSEADDR, 1);
$server doesn't exist until after the bind, but the bind won't happen (and perl will stop) at the ->new() because the port is already "taken"...
I'm quite sure I'm so far off base you're laughing - which is fine - as long as you can tell me how its _supposed_ to work :)

Thanks,
JP

-- Alexander Widdlemouse undid his bellybutton and his bum dropped off --

Replies are listed 'Best First'.
Re: Re: Re: Clean closing sockets
by trantor (Chaplain) on Aug 16, 2001 at 00:36 UTC

    setsockopt can be used immediately after calling socket and before bind, if using the functional socket interface.

    With perldoc IO::Socket you can easily find out that all you need to do is passing the Reuse option to your constructor:

    my $server = IO::Socket::INET->new(...., Reuse => 1);

    Happy recycling!

    -- TMTOWTDI

      Like, doof.
      Thanks!

      JP
      -- Alexander Widdlemouse undid his bellybutton and his bum dropped off --