IP*Works! V9

ipworks
Class Netclock

java.lang.Object
  extended by 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()
          Creates an instance of Netclock Bean.
Netclock(java.lang.String runtimeLicense)
          Creates an instance of Netclock Bean with specified run-time license.
 
Method Summary
 void addNetclockEventListener(NetclockEventListener l)
           
 java.lang.String config(java.lang.String configurationString)
          Sets or retrieves a configuration 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 from which to request the time.
 void interrupt()
          Interrupt the current method.
 boolean isIdle()
          The current status of the component.
 void removeNetclockEventListener(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 from which to request the time.
 
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()
Creates an instance of Netclock Bean.


Netclock

public Netclock(java.lang.String runtimeLicense)
Creates an instance of Netclock Bean with specified run-time license.

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 multi-homed 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 multi-homed 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 multi-homed 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 multi-homed 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.

Throws:
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.

This property is the protocol used by the component. Use this property to specify which protocol the bean will use to connect to the server. By default, this property 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.

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

Throws:
IPWorksException

getServerTime

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

This property contains 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 exception.

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

Optionally, the behavior 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 the AbsoluteTimeout configuration 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 exception.

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

Optionally, the behavior 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 the AbsoluteTimeout configuration setting.

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

Throws:
IPWorksException

getTimePort

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

This property is the UDP port on the TimeServer to which Time requests are sent. If Protocol is set to tpSNTP the component will set this property to 123.


setTimePort

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

This property is the UDP port on the TimeServer to which Time requests are sent. If Protocol is set to tpSNTP the component will set this property to 123.

Throws:
IPWorksException

getTimeServer

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

This property contains the time server from which to request the time. This property should be set to a valid internet address of a time server. The server will reply with its current time (GMT).

Time requests are sent to port TimePort on the TimeServer .


setTimeServer

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

This property contains the time server from which to request the time. This property should be set to a valid internet address of a time server. The server will reply with its current time (GMT).

Time requests are sent to port TimePort on the TimeServer .

Throws:
IPWorksException

config

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

Config is a generic method available in every bean. It is used to set and retrieve configuration settings for 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.

The bean accepts one or more of the following configuration settings . 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.

UDPPort Configuration Settings

CaptureIPPacketInfo
Used to capture the packet information
If this is set to true, the component will capture the IP packet information.The default value for this setting is False.

Note: This setting is only available in Windows.

DestinationAddress
Used to get the destination address from the packet information
If CaptureIPPacketInfo is set to true, then this will be populated with the packet's destination address when a packet is received. This information will be accessible in the DataIn event.Note: This setting is only available in Windows.

LocalHost
The name of the local host through which connections are initiated or accepted
The LocalHost setting 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 multi-homed 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 setting 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 multi-homed hosts (machines with more than one IP interface).

LocalPort
The TCP port in the local host where the bean binds
This must be set before a connection is attempted. It instructs the bean to bind to a specific port (or communication endpoint) in the local machine.Setting this to 0 (default) enables the system to choose a port at random. The chosen port will be shown by LocalPort after the connection is established.

LocalPort cannot be changed once a connection is made. Any attempt to set this when a connection is active will generate an error.

This; setting is useful when trying to connect to services that require a trusted port in the client side. An example is the remote shell (rsh) service in UNIX systems.

MaxPacketSize
The maximum length of the packets that can be received
This setting specifies the maximum size of the datagrams that the bean will accept without truncation.
ShareLocalPort
If set to True, allows more than one instance of the bean to be active on the same local port
This option must be set before the bean is activated through the Active property or it will have no effect.The default value for this setting is False.

UseConnection
Determines whether to use a connected socket
UseConnection specifies whether the bean should use a connected socket or not. The connection is defined as an association in between the local address/port and the remote address/port. As such, this is not a connection in the traditional TCP sense. What it means is only that the bean will send and receive data only to and from the specified destination.The default value for this setting is False.

QOSDSCPValue
Used to specify an arbitrary QOS/DSCP setting (optional)
UseConnection must be True to use this setting. This option allows you to specify an arbitrary DSCP value between 0 and 63. The default is 0. When set to the default value the component will not set a DSCP value.Note: This setting uses the qWAVE API is only available on Windows 7, Windows Server 2008 R2, and later.

QOSTrafficType
Used to specify QOS/DSCP settings (optional)
UseConnection must be True to use this setting. You may specify either the text or integer values: BestEffort (0), Background (1), ExcellentEffort (2), AudioVideo (3), Voice (4), and Control (5).Note: This setting uses the qWAVE API which is only available on Windows Vista and Windows Server 2008 or above.

Note: QOSTrafficType must be set before setting Active to true.

UseIPv6
Whether or not to use IPv6
By default, the component expects an IPv4 address for local and remote host properties, and will create an IPv4 socket. To use IPv6 instead, set this to True.

Socket Configuration Settings

AbsoluteTimeout
Determines whether timeouts are inactivity timeouts or absolute timeouts
If AbsoluteTimeout is set to True, any method which does not complete within Timeout seconds will be aborted. By default, AbsoluteTimeout is False, and the timeout is an inactivity timeout.
FirewallData
Used to send extra data to the firewall
When the firewall is a tunneling proxy, use this property to send custom (additional) headers to the firewall (e.g. headers for custom authentication schemes).
InBufferSize
The size in bytes of the incoming queue of the socket
This is the size of an internal queue in the TCP/IP stack. You can increase or decrease its size depending on the amount of data that you will be receiving. Increasing the value of the InBufferSize setting can provide significant improvements in performance in some cases.Some TCP/IP implementations do not support variable buffer sizes. If that is the case, when the bean is activated the InBufferSize reverts to its defined size. The same happens if you attempt to make it too large or too small.

OutBufferSize
The size in bytes of the outgoing queue of the socket
This is the size of an internal queue in the TCP/IP stack. You can increase or decrease its size depending on the amount of data that you will be sending. Increasing the value of the OutBufferSize setting can provide significant improvements in performance in some cases.Some TCP/IP implementations do not support variable buffer sizes. If that is the case, when the bean is activated the OutBufferSize reverts to its defined size. The same happens if you attempt to make it too large or too small.

Base Configuration Settings

GUIAvailable
Tells the bean whether or not a message loop is available for processing events
In a GUI-based application, long-running blocking operations may cause the application to stop responding to input until the operation returns. The bean will attempt to discover whether or not the application has a message loop and, if one is discovered, it will process events in that message loop during any such blocking operation.In some non-GUI applications an invalid message loop may be discovered that will result in errant behavior. In these cases, setting GuiAvailable to false will ensure that the bean does not attempt to process external events.

Throws:
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.

Throws:
IPWorksException

getAndSetTime

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

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

Throws:
IPWorksException

getTime

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

This method 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.

Throws:
IPWorksException

interrupt

public void interrupt()
               throws IPWorksException
Interrupt the current method.

If there is no method in progress, Interrupt simply returns, doing nothing.

Throws:
IPWorksException

addNetclockEventListener

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

removeNetclockEventListener

public void removeNetclockEventListener(NetclockEventListener l)

IP*Works! V9

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