Subject: | Replace getprotobyname("tcp") with Socket:IPPROTO_TCP |
Howdy!
Quick disclaimer: This is really just for Android. I'll try to make it as general as possible, but yeah. it's for Android. Everywhere else is sane.
On systems without getprotobyname(), or perls built with -Ud_getpbyname, setup_listener() gives an exception about getprotobyname being unimplemented.
Since the module is using the function in scalar context, it can be replaced with the IPPROTO_TCP constant from Socket.pm, which should be defined on even more systems than getprotobyname().
At least, it's defined on Android, even though getprotobyname() is a stub that spews crap to stderr and returns NULL :)
shell@android:perl-blead # ./perl -Ilib -V:d_getpbyname
d_getpbyname='undef';
shell@android:perl-blead # ./perl -Ilib -E 'getprotobyname("foo")'
Unsupported socket function "getprotobyname" called at -e line 1.
shell@android:perl-blead # ./perl -Ilib -MSocket -E 'say STDOUT Socket::IPPROTO_TCP'
6