org.apache.commons.net

Class DaytimeUDPClient

public final class DaytimeUDPClient extends DatagramSocketClient

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 {@link org.apache.commons.net.DatagramSocketClient#open open } and call {@link #getTime getTime } to retrieve the daytime string, then call {@link org.apache.commons.net.DatagramSocketClient#close close } to close the connection properly. Unlike {@link org.apache.commons.net.DaytimeTCPClient}, successive calls to {@link #getTime getTime } are permitted without re-establishing a connection. That is because UDP is a connectionless protocol and the Daytime protocol is stateless.

Author: Daniel F. Savarese

See Also:

Field Summary
static intDEFAULT_PORT
The default daytime port.
Method Summary
StringgetTime(InetAddress host, int port)
Retrieves the time string from the specified server and port and returns it.
StringgetTime(InetAddress host)
Same as getTime(host, DaytimeUDPClient.DEFAULT_PORT); **

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
The default daytime port. It is set to 13 according to RFC 867. **

Method Detail

getTime

public String getTime(InetAddress host, int port)
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.

getTime

public String getTime(InetAddress host)
Same as getTime(host, DaytimeUDPClient.DEFAULT_PORT); **