public final class NTPUDPClient extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_PORT
The default NTP port.
|
| Constructor and Description |
|---|
NTPUDPClient() |
| Modifier and Type | Method and Description |
|---|---|
TimeInfo |
getTime(InetAddress host)
Retrieves the time information from the specified server on the default NTP
port and returns it.
|
TimeInfo |
getTime(InetAddress host,
int port)
Retrieves the time information from the specified server and port and returns
it.
|
int |
getVersion()
Returns the NTP protocol version number that client sets on request packet
that is sent to remote host (e.g.
|
void |
setDefaultTimeout(int timeout)
Set the default timeout in milliseconds to use when opening a socket.
|
void |
setVersion(int version)
Sets the NTP protocol version number that client sets on request packet
communicate with remote host.
|
public static final int DEFAULT_PORT
public TimeInfo getTime(InetAddress host) throws IOException
host - The address of the server.IOException - If a NTP error occurs while retrieving the time.public TimeInfo getTime(InetAddress host, int port) throws IOException
host - The address of the server.port - The port of the service.IOException - If a NTP error occurs while retrieving the time.public int getVersion()
setVersion(int)public void setDefaultTimeout(int timeout)
timeout - The timeout in milliseconds to use for the datagram socket
connection.public void setVersion(int version)
version - the NTP protocol version number