public final class DaytimeUDPClient extends DatagramSocketClient
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.DaytimeTCPClient| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_PORT
The default daytime port.
|
_isOpen_, _socket_, _socketFactory_, _timeout_| Constructor and Description |
|---|
DaytimeUDPClient()
Constructs a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getTime(InetAddress host)
Gets the time string from the specified server and port and returns it.
|
String |
getTime(InetAddress host,
int port)
Gets the time string from the specified server and port and returns it.
|
checkOpen, close, getCharset, getDefaultTimeout, getLocalAddress, getLocalPort, getSoTimeoutDuration, isOpen, open, open, open, setCharset, setDatagramSocketFactory, setDefaultTimeout, setSoTimeoutpublic static final int DEFAULT_PORT
public String getTime(InetAddress host) throws IOException
Shorthand for getTime(host, DaytimeUDPClient.DEFAULT_PORT);
host - the hostIOException - on errorpublic String 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.