public final class NTPUDPClient extends DatagramSocketClient
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PORT
The default NTP port.
|
_isOpen_, _socket_, _socketFactory_, _timeout_
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 |
setVersion(int version)
Sets the NTP protocol version number that client sets on request packet
communicate with remote host.
|
close, getCharset, getCharsetName, getDefaultTimeout, getLocalAddress, getLocalPort, getSoTimeout, isOpen, open, open, open, setCharset, setDatagramSocketFactory, setDefaultTimeout, setSoTimeout
public static final int DEFAULT_PORT
public NTPUDPClient()
public TimeInfo getTime(InetAddress host, int port) throws IOException
host
- The address of the server.port
- The port of the service.IOException
- If an error occurs while retrieving the time.public TimeInfo getTime(InetAddress host) throws IOException
host
- The address of the server.IOException
- If an error occurs while retrieving the time.public int getVersion()
setVersion(int)
public void setVersion(int version)
version
- the NTP protocol version numberCopyright © 2001–2017 The Apache Software Foundation. All rights reserved.