|
IP*Works! V8 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--ipworks.Netclock
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 |
public static final int tpTime
public static final int tpSNTP
| Constructor Detail |
public Netclock()
| Method Detail |
public boolean isIdle()
Idle will be False if the component is currently busy (communicating
and/or waiting for an answer), and True at all other times.
public java.lang.String getLocalHost()
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.
public void setLocalHost(java.lang.String localHost)
throws IPWorksException
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.
IPWorksExceptionpublic java.lang.String getLocalTime()
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).
public int getProtocol()
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).
public void setProtocol(int protocol)
throws IPWorksException
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).
IPWorksExceptionpublic java.lang.String getServerTime()
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.
public int getTimeout()
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).
public void setTimeout(int timeout)
throws IPWorksException
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).
IPWorksExceptionpublic int getTimePort()
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.
public void setTimePort(int timePort)
throws IPWorksException
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.
IPWorksExceptionpublic java.lang.String getTimeServer()
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 .
public void setTimeServer(java.lang.String timeServer)
throws IPWorksException
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
public java.lang.String config(java.lang.String configurationString)
throws IPWorksException
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
public void doEvents()
throws IPWorksException
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
public void getAndSetTime()
throws IPWorksException
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
public void getTime()
throws IPWorksException
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
public void interrupt()
throws IPWorksException
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
public void addNetclockEventListener(ipworks.NetclockEventListener l)
throws java.util.TooManyListenersException
java.util.TooManyListenersExceptionpublic void removeNetclockEventListener(ipworks.NetclockEventListener l)
|
IP*Works! V8 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||