Package org.apache.commons.net.daytime
Class DaytimeUDPClient
java.lang.Object
org.apache.commons.net.DatagramSocketClient
org.apache.commons.net.daytime.DaytimeUDPClient
- All Implemented Interfaces:
AutoCloseable
The DaytimeUDPClient class is a UDP implementation of a client for the Daytime protocol described in RFC 867. To use the class, merely open a local datagram
socket with
open
and call getTime
to retrieve the daytime string, then call
close
to close the connection properly. Unlike
DaytimeTCPClient
, successive calls to getTime
are permitted without re-establishing a connection.
That is because UDP is a connectionless protocol and the Daytime protocol is stateless.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The default daytime port.private final byte[]
private final byte[]
Fields inherited from class org.apache.commons.net.DatagramSocketClient
_isOpen_, _socket_, _socketFactory_, _timeout_
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetTime
(InetAddress host) Same asgetTime(host, DaytimeUDPClient.DEFAULT_PORT);
getTime
(InetAddress host, int port) Retrieves the time string from the specified server and port and returns it.Methods inherited from class org.apache.commons.net.DatagramSocketClient
checkOpen, close, getCharset, getCharsetName, getDefaultTimeout, getLocalAddress, getLocalPort, getSoTimeout, getSoTimeoutDuration, isOpen, open, open, open, setCharset, setDatagramSocketFactory, setDefaultTimeout, setDefaultTimeout, setSoTimeout, setSoTimeout
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORTThe default daytime port. It is set to 13 according to RFC 867.- See Also:
-
dummyData
private final byte[] dummyData -
timeData
private final byte[] timeData
-
-
Constructor Details
-
DaytimeUDPClient
public DaytimeUDPClient()
-
-
Method Details
-
getTime
Same asgetTime(host, DaytimeUDPClient.DEFAULT_PORT);
- Parameters:
host
- the host- Returns:
- the time
- Throws:
IOException
- on error
-
getTime
Retrieves the time string from the specified server and port and returns it.- Parameters:
host
- The address of the server.port
- The port of the service.- Returns:
- The time string.
- Throws:
IOException
- If an error occurs while retrieving the time.
-