Meaningless Drivel is fun!
The moose likes Sockets and Internet Protocols and the fly likes TimeClient class that uses Time protocol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "TimeClient class that uses Time protocol" Watch "TimeClient class that uses Time protocol" New topic
Author

TimeClient class that uses Time protocol

Roger Fed
Ranch Hand

Joined: Oct 17, 2010
Posts: 82

I've developed this This client class that tries to connect to time protocol on port 37

but it give me this error
java.net.UnknownHostException: time.nist.gov
I'd be grateful if you can help me?
thanks in advance..........................

I Hear I Forget, I See I Remember, I Do I Understand.
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
Have you tried any other servers, like the ones listed in http://tf.nist.gov/tf-cgi/servers.cgi ?

Not sure if that particular server usually responds to ping, but right now it doesn't.
Roger Fed
Ranch Hand

Joined: Oct 17, 2010
Posts: 82

Thanks Ulf Dittmer for your valuable help, I've tried another server and it works well but I have one question concerning this code:
Can you explain to me what this line do???
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
It looks like the server returns the seconds since the epoch (1.1.1970) as a 4-byte value. That's actually all the server returns according to the RFC that specifies the time protocol.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: TimeClient class that uses Time protocol
 
It's not a secret anymore!