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() |
Modifier and Type | Method and Description |
---|---|
String |
getTime(InetAddress host)
Same as
getTime(host, DaytimeUDPClient.DEFAULT_PORT); |
String |
getTime(InetAddress host,
int port)
Retrieves the time string from the specified server and port and
returns it.
|
close, getCharset, getCharsetName, getDefaultTimeout, getLocalAddress, getLocalPort, getSoTimeout, isOpen, open, open, open, setCharset, setDatagramSocketFactory, setDefaultTimeout, setSoTimeout
public static final int DEFAULT_PORT
public DaytimeUDPClient()
public 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.public String getTime(InetAddress host) throws IOException
getTime(host, DaytimeUDPClient.DEFAULT_PORT);
host
- the hostIOException
- on errorCopyright © 2001–2017 The Apache Software Foundation. All rights reserved.