Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always call IO::Socket->configure even with no %args [rt.cpan.org #59984] #17452

Open
toddr opened this issue Apr 19, 2018 · 0 comments
Open
Labels
dist-IO issues in the dual-life blead-first IO distribution

Comments

@toddr
Copy link
Member

toddr commented Apr 19, 2018

Migrated from rt.cpan.org#59984 (status was 'new')

Requestors:

From [email protected] on 2010-08-01 21:08:41:

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
@toddr toddr transferred this issue from Dual-Life/IO Jan 20, 2020
@toddr toddr added Needs Triage dist-IO issues in the dual-life blead-first IO distribution labels Jan 20, 2020
@xenu xenu removed the Severity Low label Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dist-IO issues in the dual-life blead-first IO distribution
Projects
None yet
Development

No branches or pull requests

3 participants