Savarese.Org HomeORO HomeSavarese.Org/ORO Logo

com.oroinc.net
Class DaytimeUDPClient

java.lang.Object
  |
  +--com.oroinc.net.DatagramSocketClient
        |
        +--com.oroinc.net.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.

Author:
Daniel F. Savarese
See Also:
DaytimeTCPClient

Field Summary
static int DEFAULT_PORT
          The default daytime port.
 
Fields inherited from class com.oroinc.net.DatagramSocketClient
_isOpen_, _socket_, _socketFactory_, _timeout_
 
Constructor Summary
DaytimeUDPClient()
           
 
Method Summary
 java.lang.String getTime(java.net.InetAddress host)
          Same as getTime(host, DaytimeUDPClient.DEFAULT_PORT);
 java.lang.String getTime(java.net.InetAddress host, int port)
          Retrieves the time string from the specified server and port and returns it.
 
Methods inherited from class com.oroinc.net.DatagramSocketClient
close, getDefaultTimeout, getLocalAddress, getLocalPort, getSoTimeout, isOpen, open, open, open, 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.
Constructor Detail

DaytimeUDPClient

public DaytimeUDPClient()
Method Detail

getTime

public java.lang.String getTime(java.net.InetAddress host,
                                int port)
                         throws java.io.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:
java.io.IOException - If an error occurs while retrieving the time.

getTime

public java.lang.String getTime(java.net.InetAddress host)
                         throws java.io.IOException
Same as getTime(host, DaytimeUDPClient.DEFAULT_PORT);

Savarese.Org HomeORO HomeSavarese.Org/ORO Logo

Copyright © 1997-2002 Daniel F. Savarese. All Rights Reserved.