This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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
Marshal

Joined: Mar 22, 2005
Posts: 42042
    
  64
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.


Ping & DNS - my free Android networking tools app
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
Marshal

Joined: Mar 22, 2005
Posts: 42042
    
  64
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.
 
GeeCON Prague 2014
 
subject: TimeClient class that uses Time protocol