summaryrefslogtreecommitdiff
path: root/lib/Net
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-02-06 16:32:56 +0000
committerNicholas Clark <nick@ccl4.org>2008-02-06 16:32:56 +0000
commit5d6b07c5a4c042580b85248d570ee299fd102a79 (patch)
treee2a9ae36e179f9ab9c28612a4e75fa0bff818337 /lib/Net
parent913ba1b7a56ad7973e0983adb246d6506e5719e4 (diff)
downloadperl-5d6b07c5a4c042580b85248d570ee299fd102a79.tar.gz
Cope with differing prototypes for ECONNREFUSED etc on Win32 between
5.8.x and 5.10.x p4raw-id: //depot/perl@33242
Diffstat (limited to 'lib/Net')
-rw-r--r--lib/Net/Ping.pm21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/Net/Ping.pm b/lib/Net/Ping.pm
index cac3eef284..ebdbb42b76 100644
--- a/lib/Net/Ping.pm
+++ b/lib/Net/Ping.pm
@@ -16,7 +16,7 @@ use Carp;
@ISA = qw(Exporter);
@EXPORT = qw(pingecho);
-$VERSION = "2.34";
+$VERSION = "2.35";
sub SOL_IP { 0; };
sub IP_TOS { 1; };
@@ -35,11 +35,20 @@ $syn_forking = 0;
if ($^O =~ /Win32/i) {
# Hack to avoid this Win32 spewage:
# Your vendor has not defined POSIX macro ECONNREFUSED
- *ECONNREFUSED = sub() {10061;}; # "Unknown Error" Special Win32 Response?
- *ENOTCONN = sub() {10057;};
- *ECONNRESET = sub() {10054;};
- *EINPROGRESS = sub() {10036;};
- *EWOULDBLOCK = sub() {10035;};
+ my @pairs = (ECONNREFUSED => 10061, # "Unknown Error" Special Win32 Response?
+ ENOTCONN => 10057,
+ ECONNRESET => 10054,
+ EINPROGRESS => 10036,
+ EWOULDBLOCK => 10035,
+ );
+ while (my $name = shift @pairs) {
+ my $value = shift @pairs;
+ # When defined, these all are non-zero
+ unless (eval $name) {
+ no strict 'refs';
+ *{$name} = defined prototype \&{$name} ? sub () {$value} : sub {$value};
+ }
+ }
# $syn_forking = 1; # XXX possibly useful in < Win2K ?
};