DaytimeUDPClient (Apache Commons Net 3.4 API)

org.apache.commons.net.daytime

## Class DaytimeUDPClient

- java.lang.Object
- - org.apache.commons.net.DatagramSocketClient
  - - org.apache.commons.net.daytime.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 `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:
    `DaytimeTCPClient`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_PORT` The default daytime port.

    - ### Fields inherited from class org.apache.commons.net.DatagramSocketClient

      `_isOpen_, _socket_, _socketFactory_, _timeout_`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DaytimeUDPClient()`

  - ### Method Summary

    Methods
    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.

    - ### Methods inherited from class org.apache.commons.net.DatagramSocketClient

      `close, getCharset, getCharsetName, getDefaultTimeout, getLocalAddress, getLocalPort, getSoTimeout, isOpen, open, open, open, setCharset, setDatagramSocketFactory, setDefaultTimeout, setSoTimeout`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_PORT

          public static final int DEFAULT_PORT

      The default daytime port. It is set to 13 according to RFC 867.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### DaytimeUDPClient

          public DaytimeUDPClient()

  - ### Method Detail

    - #### getTime

          public String getTime(InetAddress host,
                       int port)
                         throws IOException

      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)
                         throws IOException

      Same as `getTime(host, DaytimeUDPClient.DEFAULT_PORT);`
      Parameters:
        `host` - the host
      Returns:
        the time
      Throws:
        `IOException` - on error

Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.