Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Net::Time No Response

Status
Not open for further replies.

Milleniumlegend

IS-IT--Management
Dec 16, 2003
135
Could someone please let me know how this works.

I tried the one line example from the CPAN example but this does not work. I dont get any output for localhost or any remotehost.

Many thanks in advance.
 

Don't see a one liner there?

For future reference it helps us to help you if you provide a link to what you're talking about, or some sample code.

I'm not saying we'll follow the link, but it might help ;-)

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Code:
use Net::Time qw(inet_time inet_daytime);

    print inet_time();          # use default host from Net::Config
    #print inet_time('localhost');
    print inet_time('localhost', 'tcp');
 
This does not do anything as such? I tried the above code but I am not getting any exception.
 
I investigated the module, and:

It is meant to connect to a server running a Time protocol. One such example server is time.windows.com (the one Windows XP contacts to automatically update your clock time) and time.nist.gov

Net::Config is probably returning localhost, 127.0.0.1, or your external or internal IP address. Calling inet_time on localhost is getting the same effect.

You're connecting to a time server on localhost (your own computer or local network), and localhost is not running a time server. Time servers are not implied programs, you must be explicitely running a time server in order to connect to it.
 
All I need is to connect to a remote windows server and get the system time from that box in milliseconds.

Is there anyway to do that ?
I thought Net::Time may be good enough for this. But looks like it is looking at NTP Servers.

 
If the remote server is running a time server, you can connect to that with Net::Time (assuming firewall and port issues have been taken care of ahead of time as is necessary for any kind of server program).

A time server is really simple, it just sends the number of seconds since January 1 1900. If you can't find any downloadible server programs for this, it wouldn't be hard to program one in Perl.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top