Subject: | Always call IO::Socket->configure even with no %args |
Currently, IO::Socket::new tests if any named arguments are present, and
does not call ->configure if there are no arguments. It's the actual
configure method that creates a socket handle (by a call to ->socket),
so without this, no further methods will work correctly.
In particular, the following code does not work:
my $sock = IO::Socket::UNIX->new;
$sock->setsockopt( .... );
$sock->bind( pack_sockaddr_un( $path ) );
Because the configure method doesn't actually check the full set of
named keys, it'll accept anything, so the following works fine
my $sock = IO::Socket::UNIX->new( DummyToKeepIOSocketHappy => 1 );
...
Is there any actual implementation reason why this call has to be
conditional? I've tried simply making the call unconditional in the IO
dist, and all tests still pass. There's often times, such as when
creating PF_PACKET sockets, that I'll want to create a socket handle to
set some options (such as a packet filter), before the eventual ->bind()
call to attach it to some interface. It's useful to be able to get an
unconfigured but still opened filehandle in this case.
Rather than await a 'yes', I'll fork+patch+docs+tests on github anyway,
and submit you a pull request, and you can decide on the merits there.
This will also include a fix for
https://rt.cpan.org/Ticket/Display.html?id=57671
which I am also working on.
Thanks,
--
Paul Evans