Time.pm revision 7c478bd95313f5f23a4c958a745db2134aa03244
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Copyright (c) 1995-1998 Graham Barr <gbarr@pobox.com>. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome# This program is free software; you can redistribute it and/or
199767f8919635c4928607450d9e0abb932109ceToomas Soome# modify it under the same terms as Perl itself.
199767f8919635c4928607450d9e0abb932109ceToomas Soome$VERSION = "2.09"; # $Id: //depot/libnet/Net/Time.pm#9 $
199767f8919635c4928607450d9e0abb932109ceToomas Soome my $port = (getservbyname($pname, $proto))[2] || $pnum;
199767f8919635c4928607450d9e0abb932109ceToomas Soome my $hosts = defined $host ? [ $host ] : $NetConfig{$pname . '_hosts'};
199767f8919635c4928607450d9e0abb932109ceToomas Soome return unless $me;
199767f8919635c4928607450d9e0abb932109ceToomas Soome unless defined $timeout;
199767f8919635c4928607450d9e0abb932109ceToomas Soome return undef
199767f8919635c4928607450d9e0abb932109ceToomas Soome # unpack, we | 0 to ensure we have an unsigned
199767f8919635c4928607450d9e0abb932109ceToomas Soome # the time protocol return time in seconds since 1900, convert
199767f8919635c4928607450d9e0abb932109ceToomas Soome # it to a the required format
199767f8919635c4928607450d9e0abb932109ceToomas Soome if($^O eq "MacOS") {
199767f8919635c4928607450d9e0abb932109ceToomas Soome # MacOS return seconds since 1904, 1900 was not a leap year.
199767f8919635c4928607450d9e0abb932109ceToomas Soome # otherwise return seconds since 1972, there were 17 leap years between
199767f8919635c4928607450d9e0abb932109ceToomas Soome # 1900 and 1972
199767f8919635c4928607450d9e0abb932109ceToomas Soome my $s = _socket('daytime',13,@_) || return undef;
199767f8919635c4928607450d9e0abb932109ceToomas SoomeNet::Time - time and daytime network client interface
199767f8919635c4928607450d9e0abb932109ceToomas Soome=head1 SYNOPSIS
199767f8919635c4928607450d9e0abb932109ceToomas Soome use Net::Time qw(inet_time inet_daytime);
199767f8919635c4928607450d9e0abb932109ceToomas Soome print inet_time(); # use default host from Net::Config
199767f8919635c4928607450d9e0abb932109ceToomas Soome print inet_time('localhost');
199767f8919635c4928607450d9e0abb932109ceToomas Soome print inet_time('localhost', 'tcp');
199767f8919635c4928607450d9e0abb932109ceToomas Soome print inet_daytime(); # use default host from Net::Config
199767f8919635c4928607450d9e0abb932109ceToomas Soome print inet_daytime('localhost');
199767f8919635c4928607450d9e0abb932109ceToomas Soome print inet_daytime('localhost', 'tcp');
199767f8919635c4928607450d9e0abb932109ceToomas Soome=head1 DESCRIPTION
199767f8919635c4928607450d9e0abb932109ceToomas SoomeC<Net::Time> provides subroutines that obtain the time on a remote machine.
199767f8919635c4928607450d9e0abb932109ceToomas Soome=item inet_time ( [HOST [, PROTOCOL [, TIMEOUT]]])
199767f8919635c4928607450d9e0abb932109ceToomas SoomeObtain the time on C<HOST>, or some default host if C<HOST> is not given
199767f8919635c4928607450d9e0abb932109ceToomas Soomeor not defined, using the protocol as defined in RFC868. The optional
199767f8919635c4928607450d9e0abb932109ceToomas Soomeargument C<PROTOCOL> should define the protocol to use, either C<tcp> or
199767f8919635c4928607450d9e0abb932109ceToomas SoomeC<udp>. The result will be a time value in the same units as returned
199767f8919635c4928607450d9e0abb932109ceToomas Soomeby time() or I<undef> upon failure.
199767f8919635c4928607450d9e0abb932109ceToomas Soome=item inet_daytime ( [HOST [, PROTOCOL [, TIMEOUT]]])
199767f8919635c4928607450d9e0abb932109ceToomas SoomeObtain the time on C<HOST>, or some default host if C<HOST> is not given
199767f8919635c4928607450d9e0abb932109ceToomas Soomeor not defined, using the protocol as defined in RFC867. The optional
199767f8919635c4928607450d9e0abb932109ceToomas Soomeargument C<PROTOCOL> should define the protocol to use, either C<tcp> or
199767f8919635c4928607450d9e0abb932109ceToomas SoomeC<udp>. The result will be an ASCII string or I<undef> upon failure.
199767f8919635c4928607450d9e0abb932109ceToomas Soome=head1 AUTHOR
199767f8919635c4928607450d9e0abb932109ceToomas SoomeGraham Barr <gbarr@pobox.com>
199767f8919635c4928607450d9e0abb932109ceToomas Soome=head1 COPYRIGHT
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCopyright (c) 1995-1998 Graham Barr. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas SoomeThis program is free software; you can redistribute it and/or modify
199767f8919635c4928607450d9e0abb932109ceToomas Soomeit under the same terms as Perl itself.
199767f8919635c4928607450d9e0abb932109ceToomas Soome=for html <hr>