Skip Menu |
 

This queue is for tickets about the Net-NTP CPAN distribution.

Report information
The Basics
Id: 103254
Status: open
Priority: 0/
Queue: Net-NTP

People
Owner: ABH [...] cpan.org
Requestors: DJIBEL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.4
Fixed in: (no value)



Subject: send: Cannot determine peer address at
Download (untitled) / with headers
text/plain 3.5k
Dear, I am using Strawberry Perl 5.20.2 on Windows 8.1, Windows 2008 R2... and Net::NTP 1.4. I have always this message : send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Program : #!/usr/bin/perl use strict; use warnings; use Net::NTP qw(get_ntp_response); my %response; my %inner_result = (); my $ntp_time; my @time_servers = qw ( pool.ntp.org 0.pool.ntp.org 1.pool.ntp.org north-america.pool.ntp.org 0.north-america.pool.ntp.org 1.north-america.pool.ntp.org 2.north-america.pool.ntp.org 3.north-america.pool.ntp.org time-a.timefreq.bldrdoc.gov time-c.timefreq.bldrdoc.gov utcnist.colorado.edu time.nist.gov nist1-sj.WiTime.net www.pool.ntp.org ); foreach my $time_server (@time_servers) { print("Trying time server $time_server\n"); %response = eval { get_ntp_response( $time_server, 123 ) }; if ($@) { print "Time server $time_server did not work\n$@\n"; } else { if ( !( defined( $response{"Receive Timestamp"} ) ) or $response{"Receive Timestamp"} eq "" ) { say("Receive Timestamp is bad."); } else { $ntp_time = $response{"Receive Timestamp"}; $ntp_time =~ s/\..*//; } } } Result : Trying time server pool.ntp.org Time server pool.ntp.org did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server 0.pool.ntp.org Time server 0.pool.ntp.org did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server 1.pool.ntp.org Time server 1.pool.ntp.org did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server north-america.pool.ntp.org Time server north-america.pool.ntp.org did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server 0.north-america.pool.ntp.org Time server 0.north-america.pool.ntp.org did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server 1.north-america.pool.ntp.org Time server 1.north-america.pool.ntp.org did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server 2.north-america.pool.ntp.org Time server 2.north-america.pool.ntp.org did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server 3.north-america.pool.ntp.org Time server 3.north-america.pool.ntp.org did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server time-a.timefreq.bldrdoc.gov Time server time-a.timefreq.bldrdoc.gov did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server time-c.timefreq.bldrdoc.gov Time server time-c.timefreq.bldrdoc.gov did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server utcnist.colorado.edu Time server utcnist.colorado.edu did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server time.nist.gov Time server time.nist.gov did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server nist1-sj.WiTime.net Time server nist1-sj.WiTime.net did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server www.pool.ntp.org Time server www.pool.ntp.org did not work send: Cannot determine peer address at E:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Best regards,
Subject: Re: [rt.cpan.org #103254] send: Cannot determine peer address at
Date: Wed, 1 Apr 2015 18:33:33 -0700
To: bug-Net-NTP [...] rt.cpan.org
From: Ask Bjørn Hansen <ask [...] perl.org>
I don't know anything about Windows. Patches welcome.
Download (untitled) / with headers
text/plain 292b
Le Mer 01 Avr 2015 21:33:58, ask@perl.org a écrit : Show quoted text
> I don't know anything about Windows. Patches welcome.
Dear, I have test the same program on another Windows machine with ActivePerl (5.20) and the program works. Then, I suspect a problem with Strawberry Perl but I don't know why !
Download (untitled) / with headers
text/plain 489b
On 2015-04-02 03:12:56, DJIBEL wrote: Show quoted text
> Le Mer 01 Avr 2015 21:33:58, ask@perl.org a écrit :
> > I don't know anything about Windows. Patches welcome.
> > > Dear, > > I have test the same program on another Windows machine with > ActivePerl (5.20) and the program works. Then, I suspect a problem > with Strawberry Perl but I don't know why !
What about the optional IO::Socket::INET6 dependency? Maybe it's installed in one perl distribution but not in the other? Or versions differ?
Download (untitled) / with headers
text/plain 979b
Le Jeu 02 Avr 2015 13:08:34, SREZIC a écrit : Show quoted text
> On 2015-04-02 03:12:56, DJIBEL wrote:
> > Le Mer 01 Avr 2015 21:33:58, ask@perl.org a écrit :
> > > I don't know anything about Windows. Patches welcome.
> > > > > > Dear, > > > > I have test the same program on another Windows machine with > > ActivePerl (5.20) and the program works. Then, I suspect a problem > > with Strawberry Perl but I don't know why !
> > What about the optional IO::Socket::INET6 dependency? Maybe it's > installed in one perl distribution but not in the other? Or versions > differ?
Dear, On the machine with ActivePerl, I have installed IO::Socket::INET6 and Socket6 and now, I have the same error message. But On Strawberry Perl, if I uninstall theses modules, I don't have the error message but the programe doesn't give result : Trying time server pool.ntp.org Trying time server 0.pool.ntp.org Trying time server 1.pool.ntp.org Trying time server north-america.pool.ntp.org ... Best Regards,
Download (untitled) / with headers
text/plain 1.1k
Le Jeu 02 Avr 2015 15:31:18, DJIBEL a écrit : Show quoted text
> Le Jeu 02 Avr 2015 13:08:34, SREZIC a écrit :
> > On 2015-04-02 03:12:56, DJIBEL wrote:
> > > Le Mer 01 Avr 2015 21:33:58, ask@perl.org a écrit :
> > > > I don't know anything about Windows. Patches welcome.
> > > > > > > > > Dear, > > > > > > I have test the same program on another Windows machine with > > > ActivePerl (5.20) and the program works. Then, I suspect a problem > > > with Strawberry Perl but I don't know why !
> > > > What about the optional IO::Socket::INET6 dependency? Maybe it's > > installed in one perl distribution but not in the other? Or versions > > differ?
> > Dear, > > On the machine with ActivePerl, I have installed IO::Socket::INET6 and > Socket6 and now, I have the same error message. But On Strawberry > Perl, if I uninstall theses modules, I don't have the error message > but the programe doesn't give result : > Trying time server pool.ntp.org > Trying time server 0.pool.ntp.org > Trying time server 1.pool.ntp.org > Trying time server north-america.pool.ntp.org > ... > > Best Regards,
On Strawberry Perl Windows, You have to uninstall Socket6 and IO::Socket::INET6 and Net::NTP works.
Download (untitled) / with headers
text/plain 1.4k
On 2015-04-02 15:31:18, DJIBEL wrote: Show quoted text
> Le Jeu 02 Avr 2015 13:08:34, SREZIC a écrit :
> > On 2015-04-02 03:12:56, DJIBEL wrote:
> > > Le Mer 01 Avr 2015 21:33:58, ask@perl.org a écrit :
> > > > I don't know anything about Windows. Patches welcome.
> > > > > > > > > Dear, > > > > > > I have test the same program on another Windows machine with > > > ActivePerl (5.20) and the program works. Then, I suspect a problem > > > with Strawberry Perl but I don't know why !
> > > > What about the optional IO::Socket::INET6 dependency? Maybe it's > > installed in one perl distribution but not in the other? Or versions > > differ?
> > Dear, > > On the machine with ActivePerl, I have installed IO::Socket::INET6 and > Socket6 and now, I have the same error message. But On Strawberry > Perl, if I uninstall theses modules, I don't have the error message > but the programe doesn't give result : > Trying time server pool.ntp.org > Trying time server 0.pool.ntp.org > Trying time server 1.pool.ntp.org > Trying time server north-america.pool.ntp.org > ...
Maybe it has also something to do with IO::Socket::IP vs. IO::Socket::INET? Once it was possible to replace the old INET module by the new IP module (e.g. via Acme::Override::INET). Maybe the Strawberry people did this? Another debugging aid: use something like Module::PrintUsed to see what modules and versions are in use in the script run in ActivePerl and StrawberryPerl.
Download (untitled) / with headers
text/plain 7.2k
Le Jeu 02 Avr 2015 16:58:49, SREZIC a écrit : Show quoted text
> On 2015-04-02 15:31:18, DJIBEL wrote:
> > Le Jeu 02 Avr 2015 13:08:34, SREZIC a écrit :
> > > On 2015-04-02 03:12:56, DJIBEL wrote:
> > > > Le Mer 01 Avr 2015 21:33:58, ask@perl.org a écrit :
> > > > > I don't know anything about Windows. Patches welcome.
> > > > > > > > > > > > Dear, > > > > > > > > I have test the same program on another Windows machine with > > > > ActivePerl (5.20) and the program works. Then, I suspect a > > > > problem > > > > with Strawberry Perl but I don't know why !
> > > > > > What about the optional IO::Socket::INET6 dependency? Maybe it's > > > installed in one perl distribution but not in the other? Or > > > versions > > > differ?
> > > > Dear, > > > > On the machine with ActivePerl, I have installed IO::Socket::INET6 > > and > > Socket6 and now, I have the same error message. But On Strawberry > > Perl, if I uninstall theses modules, I don't have the error message > > but the programe doesn't give result : > > Trying time server pool.ntp.org > > Trying time server 0.pool.ntp.org > > Trying time server 1.pool.ntp.org > > Trying time server north-america.pool.ntp.org > > ...
> > Maybe it has also something to do with IO::Socket::IP vs. > IO::Socket::INET? Once it was possible to replace the old INET module > by the new IP module (e.g. via Acme::Override::INET). Maybe the > Strawberry people did this? > > Another debugging aid: use something like Module::PrintUsed to see > what modules and versions are in use in the script run in ActivePerl > and StrawberryPerl.
Dear, I have made some tests. That is the program : #!/usr/bin/perl use strict; use warnings; use Net::NTP qw(get_ntp_response); use Module::PrintUsed; my %response; my %inner_result = (); my $ntp_time; my @time_servers = qw ( pool.ntp.org 0.pool.ntp.org 1.pool.ntp.org north-america.pool.ntp.org ); foreach my $time_server (@time_servers) { print("Trying time server $time_server\n"); %response = eval { get_ntp_response( $time_server, 123 ) }; if ($@) { print "Time server $time_server did not work\n$@\n"; } else { if ( !( defined( $response{"Receive Timestamp"} ) ) or $response{"Receive Timestamp"} eq "" ) { say("Receive Timestamp is bad."); } else { $ntp_time = $response{"Receive Timestamp"}; $ntp_time =~ s/\..*//; print "$ntp_time\n"; } } } print Module::PrintUsed::FormattedModulesList(); ====== Strawberry Perl 5.20.2 64 bits - Windows 8.1. Trying time server pool.ntp.org Time server pool.ntp.org did not work send: Cannot determine peer address at C:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server 0.pool.ntp.org Time server 0.pool.ntp.org did not work send: Cannot determine peer address at C:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server 1.pool.ntp.org Time server 1.pool.ntp.org did not work send: Cannot determine peer address at C:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Trying time server north-america.pool.ntp.org Time server north-america.pool.ntp.org did not work send: Cannot determine peer address at C:/Strawberry/perl/site/lib/Net/NTP.pm line 163. Modules used by net-ntp.pl: - Carp 1.3301 C:/Strawberry/perl/lib/Carp.pm - Config 5.020002 C:/Strawberry/perl/lib/Config.pm - DynaLoader 1.25 C:/Strawberry/perl/lib/DynaLoader.pm - Errno 1.2005 C:/Strawberry/perl/lib/Errno.pm - Exporter 5.71 C:/Strawberry/perl/lib/Exporter.pm - Exporter::Heavy 5.71 C:/Strawberry/perl/lib/Exporter/Heavy.pm - IO 1.31 C:/Strawberry/perl/lib/IO.pm - IO::Handle 1.35 C:/Strawberry/perl/lib/IO/Handle.pm - IO::Socket 1.38 C:/Strawberry/perl/lib/IO/Socket.pm - IO::Socket::INET 1.35 C:/Strawberry/perl/lib/IO/Socket/INET.pm - IO::Socket::INET6 2.72 C:/Strawberry/perl/vendor/lib/IO/Socket/INET6.pm - IO::Socket::UNIX 1.26 C:/Strawberry/perl/lib/IO/Socket/UNIX.pm - Module::PrintUsed 0.06 C:/Strawberry/perl/site/lib/Module/PrintUsed.pm - Net::NTP 1.4 C:/Strawberry/perl/site/lib/Net/NTP.pm - SelectSaver 1.02 C:/Strawberry/perl/lib/SelectSaver.pm - Socket 2.018 C:/Strawberry/perl/lib/Socket.pm - Socket6 0.25 C:/Strawberry/perl/vendor/lib/Socket6.pm - Symbol 1.07 C:/Strawberry/perl/lib/Symbol.pm - Time::HiRes 1.9726 C:/Strawberry/perl/lib/Time/HiRes.pm - XSLoader 0.17 C:/Strawberry/perl/lib/XSLoader.pm - base 2.22 C:/Strawberry/perl/lib/base.pm - constant 1.31 C:/Strawberry/perl/lib/constant.pm - strict 1.08 C:/Strawberry/perl/lib/strict.pm - vars 1.03 C:/Strawberry/perl/lib/vars.pm - warnings 1.23 C:/Strawberry/perl/lib/warnings.pm - warnings::register 1.03 C:/Strawberry/perl/lib/warnings/register.pm ====== ActivePerl 5.20.1 64 bits - Windows 2008 R2. Trying time server pool.ntp.org 1428050791 Trying time server 0.pool.ntp.org 1428050791 Trying time server 1.pool.ntp.org 1428050791 Trying time server north-america.pool.ntp.org 1428050791 Modules used by net-ntp.pl: - ActivePerl::Config C:/Perl/lib/ActivePerl/Config.pm - C:::Perl::site::lib::sitecustomize.pl C:/Perl/site/lib/sitecustomize .pl - Carp 1.3301 C:/Perl/lib/Carp.pm - Config 5.020001 C:/Perl/lib/Config.pm - Config_git.pl C:/Perl/lib/Config_git.pl - Config_heavy.pl C:/Perl/lib/Config_heavy.pl - DynaLoader 1.25 C:/Perl/lib/DynaLoader.pm - Errno 1.2003 C:/Perl/lib/Errno.pm - Exporter 5.71 C:/Perl/lib/Exporter.pm - Exporter::Heavy 5.71 C:/Perl/lib/Exporter/Heavy.pm - IO 1.31 C:/Perl/lib/IO.pm - IO::Handle 1.35 C:/Perl/lib/IO/Handle.pm - IO::Socket 1.37 C:/Perl/lib/IO/Socket.pm - IO::Socket::INET 1.35 C:/Perl/lib/IO/Socket/INET.pm - IO::Socket::UNIX 1.26 C:/Perl/lib/IO/Socket/UNIX.pm - List::Util 1.39 C:/Perl/lib/List/Util.pm - Module::PrintUsed 0.06 C:/Perl/site/lib/Module/PrintUsed.pm - Net::NTP 1.4 C:/Perl/site/lib/Net/NTP.pm - Scalar::Util 1.39 C:/Perl/lib/Scalar/Util.pm - SelectSaver 1.02 C:/Perl/lib/SelectSaver.pm - Socket 2.015 C:/Perl/lib/Socket.pm - Symbol 1.07 C:/Perl/lib/Symbol.pm - Time::HiRes 1.9726 C:/Perl/lib/Time/HiRes.pm - XSLoader 0.17 C:/Perl/lib/XSLoader.pm - constant 1.31 C:/Perl/lib/constant.pm - strict 1.08 C:/Perl/lib/strict.pm - vars 1.03 C:/Perl/lib/vars.pm - warnings 1.23 C:/Perl/lib/warnings.pm - warnings::register 1.03 C:/Perl/lib/warnings/register.pm We can see that in Strawberry Perl, we have IO::Socket::INET6, Socket6 and IO::Socket (1.38), Socket (2.018) In ActivePerl, we don't have IO::Socket::INET6 and Socket6. We have IO::Socket (1.35), Socket (2.015) Best Regards,
On 2015-04-03 04:54:39, DJIBEL wrote: Show quoted text
> Le Jeu 02 Avr 2015 16:58:49, SREZIC a écrit :
> > On 2015-04-02 15:31:18, DJIBEL wrote:
> > > Le Jeu 02 Avr 2015 13:08:34, SREZIC a écrit :
> > > > On 2015-04-02 03:12:56, DJIBEL wrote:
> > > > > Le Mer 01 Avr 2015 21:33:58, ask@perl.org a écrit :
> > > > > > I don't know anything about Windows. Patches welcome.
> > > > > > > > > > > > > > > Dear, > > > > > > > > > > I have test the same program on another Windows machine with > > > > > ActivePerl (5.20) and the program works. Then, I suspect a > > > > > problem > > > > > with Strawberry Perl but I don't know why !
> > > > > > > > What about the optional IO::Socket::INET6 dependency? Maybe it's > > > > installed in one perl distribution but not in the other? Or > > > > versions > > > > differ?
> > > > > > Dear, > > > > > > On the machine with ActivePerl, I have installed IO::Socket::INET6 > > > and > > > Socket6 and now, I have the same error message. But On Strawberry > > > Perl, if I uninstall theses modules, I don't have the error message > > > but the programe doesn't give result : > > > Trying time server pool.ntp.org > > > Trying time server 0.pool.ntp.org > > > Trying time server 1.pool.ntp.org > > > Trying time server north-america.pool.ntp.org > > > ...
> > > > Maybe it has also something to do with IO::Socket::IP vs. > > IO::Socket::INET? Once it was possible to replace the old INET module > > by the new IP module (e.g. via Acme::Override::INET). Maybe the > > Strawberry people did this? > > > > Another debugging aid: use something like Module::PrintUsed to see > > what modules and versions are in use in the script run in ActivePerl > > and StrawberryPerl.
> > Dear, > > I have made some tests. > That is the program : > > #!/usr/bin/perl > use strict; > use warnings; > use Net::NTP qw(get_ntp_response); > use Module::PrintUsed; > > my %response; > my %inner_result = (); > my $ntp_time; > my @time_servers = qw ( pool.ntp.org 0.pool.ntp.org 1.pool.ntp.org > north-america.pool.ntp.org ); > foreach my $time_server (@time_servers) { > print("Trying time server $time_server\n"); > %response = eval { get_ntp_response( $time_server, 123 ) }; > if ($@) { print "Time server $time_server did not work\n$@\n"; > } > else { > if ( !( defined( $response{"Receive Timestamp"} ) ) or > $response{"Receive Timestamp"} eq "" ) { > say("Receive Timestamp is bad."); > } > else { > $ntp_time = $response{"Receive Timestamp"}; > $ntp_time =~ s/\..*//; > print "$ntp_time\n"; > } > } > } > print Module::PrintUsed::FormattedModulesList(); > > ====== > Strawberry Perl 5.20.2 64 bits - Windows 8.1. > > Trying time server pool.ntp.org > Time server pool.ntp.org did not work > send: Cannot determine peer address at > C:/Strawberry/perl/site/lib/Net/NTP.pm line 163. > > Trying time server 0.pool.ntp.org > Time server 0.pool.ntp.org did not work > send: Cannot determine peer address at > C:/Strawberry/perl/site/lib/Net/NTP.pm line 163. > > Trying time server 1.pool.ntp.org > Time server 1.pool.ntp.org did not work > send: Cannot determine peer address at > C:/Strawberry/perl/site/lib/Net/NTP.pm line 163. > > Trying time server north-america.pool.ntp.org > Time server north-america.pool.ntp.org did not work > send: Cannot determine peer address at > C:/Strawberry/perl/site/lib/Net/NTP.pm line 163. > > > Modules used by net-ntp.pl: > - Carp 1.3301 C:/Strawberry/perl/lib/Carp.pm > - Config 5.020002 C:/Strawberry/perl/lib/Config.pm > - DynaLoader 1.25 > C:/Strawberry/perl/lib/DynaLoader.pm > - Errno 1.2005 C:/Strawberry/perl/lib/Errno.pm > - Exporter 5.71 > C:/Strawberry/perl/lib/Exporter.pm > - Exporter::Heavy 5.71 > C:/Strawberry/perl/lib/Exporter/Heavy.pm > - IO 1.31 C:/Strawberry/perl/lib/IO.pm > - IO::Handle 1.35 > C:/Strawberry/perl/lib/IO/Handle.pm > - IO::Socket 1.38 > C:/Strawberry/perl/lib/IO/Socket.pm > - IO::Socket::INET 1.35 > C:/Strawberry/perl/lib/IO/Socket/INET.pm > - IO::Socket::INET6 2.72 > C:/Strawberry/perl/vendor/lib/IO/Socket/INET6.pm > - IO::Socket::UNIX 1.26 > C:/Strawberry/perl/lib/IO/Socket/UNIX.pm > - Module::PrintUsed 0.06 > C:/Strawberry/perl/site/lib/Module/PrintUsed.pm > - Net::NTP 1.4 > C:/Strawberry/perl/site/lib/Net/NTP.pm > - SelectSaver 1.02 > C:/Strawberry/perl/lib/SelectSaver.pm > - Socket 2.018 C:/Strawberry/perl/lib/Socket.pm > - Socket6 0.25 > C:/Strawberry/perl/vendor/lib/Socket6.pm > - Symbol 1.07 C:/Strawberry/perl/lib/Symbol.pm > - Time::HiRes 1.9726 > C:/Strawberry/perl/lib/Time/HiRes.pm > - XSLoader 0.17 > C:/Strawberry/perl/lib/XSLoader.pm > - base 2.22 C:/Strawberry/perl/lib/base.pm > - constant 1.31 > C:/Strawberry/perl/lib/constant.pm > - strict 1.08 C:/Strawberry/perl/lib/strict.pm > - vars 1.03 C:/Strawberry/perl/lib/vars.pm > - warnings 1.23 > C:/Strawberry/perl/lib/warnings.pm > - warnings::register 1.03 > C:/Strawberry/perl/lib/warnings/register.pm > > ====== > ActivePerl 5.20.1 64 bits - Windows 2008 R2. > > Trying time server pool.ntp.org > 1428050791 > Trying time server 0.pool.ntp.org > 1428050791 > Trying time server 1.pool.ntp.org > 1428050791 > Trying time server north-america.pool.ntp.org > 1428050791 > > Modules used by net-ntp.pl: > - ActivePerl::Config C:/Perl/lib/ActivePerl/Config.pm > - C:::Perl::site::lib::sitecustomize.pl > C:/Perl/site/lib/sitecustomize > .pl > - Carp 1.3301 C:/Perl/lib/Carp.pm > - Config 5.020001 C:/Perl/lib/Config.pm > - Config_git.pl C:/Perl/lib/Config_git.pl > - Config_heavy.pl C:/Perl/lib/Config_heavy.pl > - DynaLoader 1.25 C:/Perl/lib/DynaLoader.pm > - Errno 1.2003 C:/Perl/lib/Errno.pm > - Exporter 5.71 C:/Perl/lib/Exporter.pm > - Exporter::Heavy 5.71 C:/Perl/lib/Exporter/Heavy.pm > - IO 1.31 C:/Perl/lib/IO.pm > - IO::Handle 1.35 C:/Perl/lib/IO/Handle.pm > - IO::Socket 1.37 C:/Perl/lib/IO/Socket.pm > - IO::Socket::INET 1.35 C:/Perl/lib/IO/Socket/INET.pm > - IO::Socket::UNIX 1.26 C:/Perl/lib/IO/Socket/UNIX.pm > - List::Util 1.39 C:/Perl/lib/List/Util.pm > - Module::PrintUsed 0.06 > C:/Perl/site/lib/Module/PrintUsed.pm > - Net::NTP 1.4 C:/Perl/site/lib/Net/NTP.pm > - Scalar::Util 1.39 C:/Perl/lib/Scalar/Util.pm > - SelectSaver 1.02 C:/Perl/lib/SelectSaver.pm > - Socket 2.015 C:/Perl/lib/Socket.pm > - Symbol 1.07 C:/Perl/lib/Symbol.pm > - Time::HiRes 1.9726 C:/Perl/lib/Time/HiRes.pm > - XSLoader 0.17 C:/Perl/lib/XSLoader.pm > - constant 1.31 C:/Perl/lib/constant.pm > - strict 1.08 C:/Perl/lib/strict.pm > - vars 1.03 C:/Perl/lib/vars.pm > - warnings 1.23 C:/Perl/lib/warnings.pm > - warnings::register 1.03 C:/Perl/lib/warnings/register.pm > > > We can see that in Strawberry Perl, we have IO::Socket::INET6, Socket6 > and IO::Socket (1.38), Socket (2.018) > In ActivePerl, we don't have IO::Socket::INET6 and Socket6. We have > IO::Socket (1.35), Socket (2.015)
The state of IO::Socket is somewhat confusing. On CPAN there's only an ancient 1.31 available. corelist says that perl 5.20.1 should come with 1.37, but ActiveState ships only 1.35. Maybe they are aware of some incompatibilities?
RT-Send-CC: ABH [...] cpan.org
Download (untitled) / with headers
text/plain 384b
I have a file that works on Windows 7 64 bit, and another on Windows XP 32 bit. I do not remember where I got the answers those number of years ago. I will simply upload the Net::NTP files that work. On Windows 7 64 bit, install Perl as usual, then install Net::NTP as usual, then copy the NTP_mhn.pm file to NTP.pm, overwriting the original. My thanks to whoever gave me the fix.
Subject: NTP.pm
Download NTP.pm
text/x-perl 7.6k
package Net::NTP; use 5.008; use strict; use warnings; use IO::Socket; use constant HAVE_SOCKET_INET6 => eval { require IO::Socket::INET6 }; use Time::HiRes qw(time); require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw( get_ntp_response ); our $VERSION = '1.4'; our $TIMEOUT = 5; our %MODE = ( '0' => 'reserved', '1' => 'symmetric active', '2' => 'symmetric passive', '3' => 'client', '4' => 'server', '5' => 'broadcast', '6' => 'reserved for NTP control message', '7' => 'reserved for private use' ); our %STRATUM = ( '0' => 'unspecified or unavailable', '1' => 'primary reference (e.g., radio clock)', ); for (2 .. 15) { $STRATUM{$_} = 'secondary reference (via NTP or SNTP)'; } for (16 .. 255) { $STRATUM{$_} = 'reserved'; } our %STRATUM_ONE_TEXT = ( 'LOCL' => 'uncalibrated local clock used as a primary reference for a subnet without external means of synchronization', 'PPS' => 'atomic clock or other pulse-per-second source individually calibrated to national standards', 'ACTS' => 'NIST dialup modem service', 'USNO' => 'USNO modem service', 'PTB' => 'PTB (Germany) modem service', 'TDF' => 'Allouis (France) Radio 164 kHz', 'DCF' => 'Mainflingen (Germany) Radio 77.5 kHz', 'MSF' => 'Rugby (UK) Radio 60 kHz', 'WWV' => 'Ft. Collins (US) Radio 2.5, 5, 10, 15, 20 MHz', 'WWVB' => 'Boulder (US) Radio 60 kHz', 'WWVH' => 'Kaui Hawaii (US) Radio 2.5, 5, 10, 15 MHz', 'CHU' => 'Ottawa (Canada) Radio 3330, 7335, 14670 kHz', 'LORC' => 'LORAN-C radionavigation system', 'OMEG' => 'OMEGA radionavigation system', 'GPS' => 'Global Positioning Service', 'GOES' => 'Geostationary Orbit Environment Satellite', ); our %LEAP_INDICATOR = ( '0' => 'no warning', '1' => 'last minute has 61 seconds', '2' => 'last minute has 59 seconds)', '3' => 'alarm condition (clock not synchronized)' ); use constant NTP_ADJ => 2208988800; my @ntp_packet_fields = ( 'Leap Indicator', 'Version Number', 'Mode', 'Stratum', 'Poll Interval', 'Precision', 'Root Delay', 'Root Dispersion', 'Reference Clock Identifier', 'Reference Timestamp', 'Originate Timestamp', 'Receive Timestamp', 'Transmit Timestamp', ); my $frac2bin = sub { my $bin = ''; my $frac = shift; while (length($bin) < 32) { $bin = $bin . int($frac * 2); $frac = ($frac * 2) - (int($frac * 2)); } return $bin; }; my $bin2frac = sub { my @bin = split '', shift; my $frac = 0; while (@bin) { $frac = ($frac + pop @bin) / 2; } return $frac; }; my $percision = sub { my $number = shift; if ($number > 127) { $number -= 255; } return sprintf("%1.4e", 2**$number); }; my $unpack_ip = sub { my $ip; my $stratum = shift; my $tmp_ip = shift; if ($stratum < 2) { $ip = unpack("A4", pack("H8", $tmp_ip)); } else { $ip = sprintf("%d.%d.%d.%d", unpack("C4", pack("H8", $tmp_ip))); } return $ip; }; sub get_ntp_response { my $host = shift || 'localhost'; my $port = shift || 'ntp'; my %args = ( Proto => 'udp', PeerHost => $host, PeerPort => $port ); my $sock; if (HAVE_SOCKET_INET6) { $sock = IO::Socket::INET6->new(%args); } else { $sock = IO::Socket::INET->new(%args); } die $@ unless $sock; my %tmp_pkt; my %packet; my $data; my $client_localtime = time; my $client_adj_localtime = $client_localtime + NTP_ADJ; my $client_frac_localtime = $frac2bin->($client_adj_localtime); my $ntp_msg = pack("B8 C3 N10 B32", '00011011', (0) x 12, int($client_adj_localtime), $client_frac_localtime); $sock->send($ntp_msg) or die "send() failed: $!\n"; eval { local $SIG{ALRM} = sub { die "Net::NTP timed out getting NTP packet\n"; }; alarm($TIMEOUT); $sock->recv($data, 960) or die "recv() failed: $!\n"; alarm(0); }; alarm 0; my $client_recvtime = time; if (my $err = $@) { return if $err =~ m/^Net::NTP timed out/; die $err; } my @ntp_fields = qw/byte1 stratum poll precision/; push @ntp_fields, qw/delay delay_fb disp disp_fb ident/; push @ntp_fields, qw/ref_time ref_time_fb/; push @ntp_fields, qw/org_time org_time_fb/; push @ntp_fields, qw/recv_time recv_time_fb/; push @ntp_fields, qw/trans_time trans_time_fb/; @tmp_pkt{@ntp_fields} = unpack("a C3 n B16 n B16 H8 N B32 N B32 N B32 N B32", $data); @packet{@ntp_packet_fields} = ( (unpack("C", $tmp_pkt{byte1} & "\xC0") >> 6), (unpack("C", $tmp_pkt{byte1} & "\x38") >> 3), (unpack("C", $tmp_pkt{byte1} & "\x07")), $tmp_pkt{stratum}, (sprintf("%0.4f", $tmp_pkt{poll})), $tmp_pkt{precision} - 255, ($bin2frac->($tmp_pkt{delay_fb})), (sprintf("%0.4f", $tmp_pkt{disp})), $unpack_ip->($tmp_pkt{stratum}, $tmp_pkt{ident}), (($tmp_pkt{ref_time} += $bin2frac->($tmp_pkt{ref_time_fb})) -= NTP_ADJ), (($tmp_pkt{org_time} += $bin2frac->($tmp_pkt{org_time_fb})) -= NTP_ADJ), (($tmp_pkt{recv_time} += $bin2frac->($tmp_pkt{recv_time_fb})) -= NTP_ADJ), (($tmp_pkt{trans_time} += $bin2frac->($tmp_pkt{trans_time_fb})) -= NTP_ADJ) ); my $dest_org = sprintf "%0.5f", (($client_recvtime - $client_localtime)); my $recv_trans = sprintf "%0.5f", ($packet{'Receive Timestamp'} - $packet{'Transmit Timestamp'}); my $delay = sprintf "%0.5f", ($dest_org + $recv_trans); my $recv_org = $packet{'Receive Timestamp'} - $client_recvtime; my $trans_dest = $packet{'Transmit Timestamp'} - $client_localtime; my $offset = ($recv_org + $trans_dest) / 2; # Calculated offset / delay $packet{Offset} = $offset; $packet{Delay} = $delay; return %packet; } 1; __END__ =head1 NAME Net::NTP - Perl extension for decoding NTP server responses =head1 SYNOPSIS use Net::NTP qw(get_ntp_response); my %response = get_ntp_response(); =head1 ABSTRACT All this module does is send a packet to an NTP server and then decode the packet recieved into it's respective parts - as outlined in RFC1305 and RFC2030. =head1 DESCRIPTION This module exports a single method (get_ntp_response) and returns an associative array based upon RFC1305 and RFC2030. The response from the server is "humanized" to a point that further processing of th information recieved from the server can be manipulated. For example: timestamps are in epoch, so one could use the localtime function to produce an even more "human" representation of the timestamp. =head2 EXPORT get_ntp_response(<server>, <port>); This module exports a single method - get_ntp_response. It takes the server as the first argument (localhost is the default) and port to send/recieve the packets (ntp or 123 bu default). It returns an associative array of the various parts of the packet as outlined in RFC1305. It "normalizes" or "humanizes" various parts of the packet. For example: all the timestamps are in epoch, NOT hexidecimal. =head1 SEE ALSO perl, IO::Socket, RFC1305, RFC2030 =head1 AUTHOR Now maintained by Ask Bjørn Hansen, E<lt>ask@develooper.com<gt> Originally by James G. Willmore, E<lt>jwillmore (at) adelphia.net<gt> or E<lt>owner (at) ljcomputing.net<gt> Special thanks to Ralf D. Kloth E<lt>ralf (at) qrq.de<gt> for the code to decode NTP packets. =head1 COPYRIGHT AND LICENSE Copyright 2009 by Ask Bjørn Hansen; 2004 by James G. Willmore This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut
Subject: NTP_mhn.pm
Download NTP_mhn.pm
text/x-perl 6.9k
package Net::NTP; use 5.006; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw( get_ntp_response ); our $VERSION = '1.3'; our $TIMEOUT = 60; our %MODE = ( '0' => 'reserved', '1' => 'symmetric active', '2' => 'symmetric passive', '3' => 'client', '4' => 'server', '5' => 'broadcast', '6' => 'reserved for NTP control message', '7' => 'reserved for private use' ); our %STRATUM = ( '0' => 'unspecified or unavailable', '1' => 'primary reference (e.g., radio clock)', ); for (2 .. 15) { $STRATUM{$_} = 'secondary reference (via NTP or SNTP)'; } for (16 .. 255) { $STRATUM{$_} = 'reserved'; } our %STRATUM_ONE_TEXT = ( 'LOCL' => 'uncalibrated local clock used as a primary reference for a subnet without external means of synchronization', 'PPS' => 'atomic clock or other pulse-per-second source individually calibrated to national standards', 'ACTS' => 'NIST dialup modem service', 'USNO' => 'USNO modem service', 'PTB' => 'PTB (Germany) modem service', 'TDF' => 'Allouis (France) Radio 164 kHz', 'DCF' => 'Mainflingen (Germany) Radio 77.5 kHz', 'MSF' => 'Rugby (UK) Radio 60 kHz', 'WWV' => 'Ft. Collins (US) Radio 2.5, 5, 10, 15, 20 MHz', 'WWVB' => 'Boulder (US) Radio 60 kHz', 'WWVH' => 'Kaui Hawaii (US) Radio 2.5, 5, 10, 15 MHz', 'CHU' => 'Ottawa (Canada) Radio 3330, 7335, 14670 kHz', 'LORC' => 'LORAN-C radionavigation system', 'OMEG' => 'OMEGA radionavigation system', 'GPS' => 'Global Positioning Service', 'GOES' => 'Geostationary Orbit Environment Satellite', ); our %LEAP_INDICATOR = ( '0' => 'no warning', '1' => 'last minute has 61 seconds', '2' => 'last minute has 59 seconds)', '3' => 'alarm condition (clock not synchronized)' ); use constant NTP_ADJ => 2208988800; my @ntp_packet_fields = ( 'Leap Indicator', 'Version Number', 'Mode', 'Stratum', 'Poll Interval', 'Precision', 'Root Delay', 'Root Dispersion', 'Reference Clock Identifier', 'Reference Timestamp', 'Originate Timestamp', 'Receive Timestamp', 'Transmit Timestamp', ); my $frac2bin = sub { my $bin = ''; my $frac = shift; while (length($bin) < 32) { $bin = $bin . int($frac * 2); $frac = ($frac * 2) - (int($frac * 2)); } return $bin; }; my $bin2frac = sub { my @bin = split '', shift; my $frac = 0; while (@bin) { $frac = ($frac + pop @bin) / 2; } return $frac; }; my $percision = sub { my $number = shift; if ($number > 127) { $number -= 255; } return sprintf("%1.4e", 2**$number); }; my $unpack_ip = sub { my $ip; my $stratum = shift; my $tmp_ip = shift; if ($stratum < 2) { $ip = unpack("A4", pack("H8", $tmp_ip)); } else { $ip = sprintf("%d.%d.%d.%d", unpack("C4", pack("H8", $tmp_ip))); } return $ip; }; sub get_ntp_response { use IO::Socket; use constant HAVE_SOCKET_INET6 => eval { require IO::Socket::INET6 }; my $host = shift || 'localhost'; my $port = shift || 'ntp'; my %args = ( Proto => 'udp', PeerHost => $host, PeerPort => $port ); my $sock; # if (HAVE_SOCKET_INET6) { # $sock = IO::Socket::INET6->new(%args); # } # else { $sock = IO::Socket::INET->new(%args); # } die $@ unless $sock; my %tmp_pkt; my %packet; my $data; my $client_localtime = time; my $client_adj_localtime = $client_localtime + NTP_ADJ; my $client_frac_localtime = $frac2bin->($client_adj_localtime); my $ntp_msg = pack("B8 C3 N10 B32", '00011011', (0) x 12, int($client_localtime), $client_frac_localtime); $sock->send($ntp_msg) or die "send() failed: $!\n"; eval { local $SIG{ALRM} = sub { die "Net::NTP timed out geting NTP packet\n"; }; alarm($TIMEOUT); $sock->recv($data, 960) or die "recv() failed: $!\n"; alarm(0); }; if ($@) { die "$@"; } my @ntp_fields = qw/byte1 stratum poll precision/; push @ntp_fields, qw/delay delay_fb disp disp_fb ident/; push @ntp_fields, qw/ref_time ref_time_fb/; push @ntp_fields, qw/org_time org_time_fb/; push @ntp_fields, qw/recv_time recv_time_fb/; push @ntp_fields, qw/trans_time trans_time_fb/; @tmp_pkt{@ntp_fields} = unpack("a C3 n B16 n B16 H8 N B32 N B32 N B32 N B32", $data); @packet{@ntp_packet_fields} = ( (unpack("C", $tmp_pkt{byte1} & "\xC0") >> 6), (unpack("C", $tmp_pkt{byte1} & "\x38") >> 3), (unpack("C", $tmp_pkt{byte1} & "\x07")), $tmp_pkt{stratum}, (sprintf("%0.4f", $tmp_pkt{poll})), $tmp_pkt{precision} - 255, ($bin2frac->($tmp_pkt{delay_fb})), (sprintf("%0.4f", $tmp_pkt{disp})), $unpack_ip->($tmp_pkt{stratum}, $tmp_pkt{ident}), (($tmp_pkt{ref_time} += $bin2frac->($tmp_pkt{ref_time_fb})) -= NTP_ADJ), (($tmp_pkt{org_time} += $bin2frac->($tmp_pkt{org_time_fb}))), (($tmp_pkt{recv_time} += $bin2frac->($tmp_pkt{recv_time_fb})) -= NTP_ADJ), (($tmp_pkt{trans_time} += $bin2frac->($tmp_pkt{trans_time_fb})) -= NTP_ADJ) ); return %packet; } 1; __END__ =head1 NAME Net::NTP - Perl extension for decoding NTP server responses =head1 SYNOPSIS use Net::NTP qw(get_ntp_response); my %response = get_ntp_response(); =head1 ABSTRACT All this module does is send a packet to an NTP server and then decode the packet recieved into it's respective parts - as outlined in RFC1305 and RFC2030. =head1 DESCRIPTION This module exports a single method (get_ntp_response) and returns an associative array based upon RFC1305 and RFC2030. The response from the server is "humanized" to a point that further processing of th information recieved from the server can be manipulated. For example: timestamps are in epoch, so one could use the localtime function to produce an even more "human" representation of the timestamp. =head2 EXPORT get_ntp_response(<server>, <port>); This module exports a single method - get_ntp_response. It takes the server as the first argument (localhost is the default) and port to send/recieve the packets (ntp or 123 bu default). It returns an associative array of the various parts of the packet as outlined in RFC1305. It "normalizes" or "humanizes" various parts of the packet. For example: all the timestamps are in epoch, NOT hexidecimal. =head1 SEE ALSO perl, IO::Socket, RFC1305, RFC2030 =head1 AUTHOR Now maintained by Ask Bjørn Hansen, E<lt>ask@develooper.com<gt> Originally by James G. Willmore, E<lt>jwillmore (at) adelphia.net<gt> or E<lt>owner (at) ljcomputing.net<gt> Special thanks to Ralf D. Kloth E<lt>ralf (at) qrq.de<gt> for the code to decode NTP packets. =head1 COPYRIGHT AND LICENSE Copyright 2009 by Ask Bjørn Hansen; 2004 by James G. Willmore This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.