IP*Works! V8

ipworks
Class Netclock

java.lang.Object
  |
  +--ipworks.Netclock

public class Netclock
extends java.lang.Object

The NetClock bean provides the current (GMT) time from an Internet Time Server.

The NetClock component implements a standard Time Protocol client as specified in RFC 868, as well as an SNTP Protocol.

The address of the Time Server is provided in the TimeServer property. You get the time by calling the GetTime method.

The bean also allows you to synchronize your system time with that of the TimeServer . This is done through the GetAndSetTime method. Calling GetAndSetTime will request the time from the server and then set the system clock to match it.


Field Summary
static int tpSNTP
           
static int tpTime
           
 
Constructor Summary
Netclock()
           
 
Method Summary
 void addNetclockEventListener(ipworks.NetclockEventListener l)
           
 java.lang.String config(java.lang.String configurationString)
          Sets or retrieves a beanconfiguration setting.
 void doEvents()
          Processes events from the internal message queue.
 void getAndSetTime()
          Same as the GetTime method, but system clock is also set to the received time.
 java.lang.String getLocalHost()
          The name of the local host or user-assigned IP interface through which connections are initiated or accepted.
 java.lang.String getLocalTime()
          The time returned by the TimeServer converted to local time.
 int getProtocol()
          The protocol used by the component.
 java.lang.String getServerTime()
          The time returned by the TimeServer .
 void getTime()
          Sends a time request to the TimeServer to get the current time.
 int getTimeout()
          A timeout for the bean.
 int getTimePort()
          The UDP port where the remote Time server is listening.
 java.lang.String getTimeServer()
          The time server to request the time from.
 void interrupt()
          Sends a time request to the TimeServer to get the current time.
 boolean isIdle()
          The current status of the component.
 void removeNetclockEventListener(ipworks.NetclockEventListener l)
           
 void setLocalHost(java.lang.String localHost)
          The name of the local host or user-assigned IP interface through which connections are initiated or accepted.
 void setProtocol(int protocol)
          The protocol used by the component.
 void setTimeout(int timeout)
          A timeout for the bean.
 void setTimePort(int timePort)
          The UDP port where the remote Time server is listening.
 void setTimeServer(java.lang.String timeServer)
          The time server to request the time from.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tpTime

public static final int tpTime
See Also:
Constant Field Values

tpSNTP

public static final int tpSNTP
See Also:
Constant Field Values
Constructor Detail

Netclock

public Netclock()
Method Detail

isIdle

public boolean isIdle()
The current status of the component.

Idle will be False if the component is currently busy (communicating and/or waiting for an answer), and True at all other times.


getLocalHost

public java.lang.String getLocalHost()
The name of the local host or user-assigned IP interface through which connections are initiated or accepted.

The LocalHost property contains the name of the local host as obtained by the gethostname() system call, or if the user has assigned an IP address, the value of that address.

In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the bean initiate connections (or accept in the case of server beans) only through that interface.

If the bean is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).

NOTE: LocalHost is not persistent. You must always set it in code, and never in the property window.


setLocalHost

public void setLocalHost(java.lang.String localHost)
                  throws IPWorksException
The name of the local host or user-assigned IP interface through which connections are initiated or accepted.

The LocalHost property contains the name of the local host as obtained by the gethostname() system call, or if the user has assigned an IP address, the value of that address.

In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the bean initiate connections (or accept in the case of server beans) only through that interface.

If the bean is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).

NOTE: LocalHost is not persistent. You must always set it in code, and never in the property window.

IPWorksException

getLocalTime

public java.lang.String getLocalTime()
The time returned by the TimeServer converted to local time.

The server provides Greenwich Mean Time (GMT). This property contains the corresponding local time formatted as "MM/DD/YYYY HH:MM:SS" (where "HH" is in 24 hour format).


getProtocol

public int getProtocol()
The protocol used by the component.

Use this property to specify which protocol the bean will use to connect to the server. By default, the Protocol is tpTimeProtocol (0). The SNTP protocol may be selected by setting this property to tpSNTP (1).


setProtocol

public void setProtocol(int protocol)
                 throws IPWorksException
The protocol used by the component.

Use this property to specify which protocol the bean will use to connect to the server. By default, the Protocol is tpTimeProtocol (0). The SNTP protocol may be selected by setting this property to tpSNTP (1).

IPWorksException

getServerTime

public java.lang.String getServerTime()
The time returned by the TimeServer .

The time is Greenwich Mean Time (GMT) formatted as "MM/DD/YYYY HH:MM:SS GMT" (where "HH" is in 24 hour format).

For the corresponding local time, please consult the LocalTime property.


getTimeout

public int getTimeout()
A timeout for the bean.

If the Timeout property is set to 0, all operations will run uninterrupted until successful completion, or an error condition is encountered.

If Timeout is set to a positive value, the bean will wait for the operation to complete before returning control.

The bean will use DoEvents to enter an efficient wait loop during any potential waiting period, making sure that all system events are processed immediately as they arrive. This ensures that the host application does not "freeze" and remains responsive.

If Timeout expires, and the operation is not yet complete, the bean throws an IPWorksException raises an IPWorksException exception .

Please note that by default, all timeouts are inactivity timeouts , i.e. the timeout period is extended by Timeout seconds when data is successfully sent or received.

Optionally, the behaviour of the bean may be changed to absolute timeouts , i.e. the bean will wait for a maximum of Timeout seconds since the beginning of the operation, without extending the timeout period during communications.

This behavior is controlled by theAbsoluteTimeoutconfiguration setting.

The default value for the Timeout property is 60 (seconds).


setTimeout

public void setTimeout(int timeout)
                throws IPWorksException
A timeout for the bean.

If the Timeout property is set to 0, all operations will run uninterrupted until successful completion, or an error condition is encountered.

If Timeout is set to a positive value, the bean will wait for the operation to complete before returning control.

The bean will use DoEvents to enter an efficient wait loop during any potential waiting period, making sure that all system events are processed immediately as they arrive. This ensures that the host application does not "freeze" and remains responsive.

If Timeout expires, and the operation is not yet complete, the bean throws an IPWorksException raises an IPWorksException exception .

Please note that by default, all timeouts are inactivity timeouts , i.e. the timeout period is extended by Timeout seconds when data is successfully sent or received.

Optionally, the behaviour of the bean may be changed to absolute timeouts , i.e. the bean will wait for a maximum of Timeout seconds since the beginning of the operation, without extending the timeout period during communications.

This behavior is controlled by theAbsoluteTimeoutconfiguration setting.

The default value for the Timeout property is 60 (seconds).

IPWorksException

getTimePort

public int getTimePort()
The UDP port where the remote Time server is listening.

The TimePort is the UDP port on the TimeServer to send Time requests to. If Protocol is set to tpSNTP the component will set TimePort to 123.


setTimePort

public void setTimePort(int timePort)
                 throws IPWorksException
The UDP port where the remote Time server is listening.

The TimePort is the UDP port on the TimeServer to send Time requests to. If Protocol is set to tpSNTP the component will set TimePort to 123.

IPWorksException

getTimeServer

public java.lang.String getTimeServer()
The time server to request the time from.

This property should be set to a valid internet address of a time server (default is "clock.nist.gov"). The server will reply with its current time (GMT).

Time request are sent to port TimePort (default 37) on the TimeServer .


setTimeServer

public void setTimeServer(java.lang.String timeServer)
                   throws IPWorksException
The time server to request the time from.

This property should be set to a valid internet address of a time server (default is "clock.nist.gov"). The server will reply with its current time (GMT).

Time request are sent to port TimePort (default 37) on the TimeServer .

IPWorksException

config

public java.lang.String config(java.lang.String configurationString)
                        throws IPWorksException
Sets or retrieves a beanconfiguration setting.

Config is a generic method available in every bean. It is used to set and retrieveconfiguration settingsfor the bean.

Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the bean, access to these internal properties is provided through the Config method.

To set a configuration setting named PROPERTY , you must call Config("PROPERTY=VALUE") , where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a configuration setting, you must call Config("PROPERTY") . The value will be returned as a string.

IPWorksException

doEvents

public void doEvents()
              throws IPWorksException
Processes events from the internal message queue.

When DoEvents is called, the bean processes any available events. If no events are available, it waits for a preset period of time, and then returns.

IPWorksException

getAndSetTime

public void getAndSetTime()
                   throws IPWorksException
Same as the GetTime method, but system clock is also set to the received time.

Same as the GetTime method, but the system clock is also set to the received time (adjusted for timezone differences).

IPWorksException

getTime

public void getTime()
             throws IPWorksException
Sends a time request to the TimeServer to get the current time.

Sends a time request to the TimeServer on port 37. The reply is provided in the ServerTime property, and the equivalent local time is provided in the LocalTime property.

IPWorksException

interrupt

public void interrupt()
               throws IPWorksException
Sends a time request to the TimeServer to get the current time.

Sends a time request to the TimeServer on port 37. The reply is provided in the ServerTime property, and the equivalent local time is provided in the LocalTime property.

IPWorksException

addNetclockEventListener

public void addNetclockEventListener(ipworks.NetclockEventListener l)
                              throws java.util.TooManyListenersException
java.util.TooManyListenersException

removeNetclockEventListener

public void removeNetclockEventListener(ipworks.NetclockEventListener l)

IP*Works! V8

Copyright (c) 2007 /n software inc. - All rights reserved.