|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.net.DatagramSocketClient org.apache.commons.net.ntp.NTPUDPClient
public final class NTPUDPClient
The NTPUDPClient class is a UDP implementation of a client for the Network Time Protocol (NTP) described in RFC 1305 as well as the Simple Network Time Protocol (SNTP) in RFC-2030. To use the class, merely open a local datagram socket with open and call getTime to retrieve the time. Then call close to close the connection properly. Successive calls to getTime are permitted without re-establishing a connection. That is because UDP is a connectionless protocol and the Network Time Protocol is stateless.
Field Summary | |
---|---|
static int |
DEFAULT_PORT
The default NTP port. |
Fields inherited from class org.apache.commons.net.DatagramSocketClient |
---|
_isOpen_, _socket_, _socketFactory_, _timeout_ |
Constructor Summary | |
---|---|
NTPUDPClient()
|
Method Summary | |
---|---|
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. |
Methods inherited from class org.apache.commons.net.DatagramSocketClient |
---|
close, getDefaultTimeout, getLocalAddress, getLocalPort, getSoTimeout, isOpen, open, open, open, setDatagramSocketFactory, setDefaultTimeout, setSoTimeout |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_PORT
Constructor Detail |
---|
public NTPUDPClient()
Method Detail |
---|
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 number
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |