aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
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: 42285
    
  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: 42285
    
  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.
 
Don't get me started about those stupid light bulbs.
 
subject: TimeClient class that uses Time protocol