org.apache.commons.net
Class DaytimeUDPClient
public final class DaytimeUDPClient
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.
DaytimeTCPClient
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, getDefaultTimeout, getLocalAddress, getLocalPort, getSoTimeout, isOpen, open, open, open, setDatagramSocketFactory, setDefaultTimeout, setSoTimeout |
DEFAULT_PORT
public static final int DEFAULT_PORT
The default daytime port. It is set to 13 according to RFC 867. **
- 13
getTime
public String getTime(InetAddress host)
throws IOException Same as getTime(host, DaytimeUDPClient.DEFAULT_PORT); **
getTime
public String getTime(InetAddress host,
int port)
throws IOException
Retrieves the time string from the specified server and port and
returns it.
host - The address of the server.port - The port of the service.
- The time string.