IP*Works! V9

ipworks
Class Tftp

java.lang.Object
  extended by ipworks.Tftp

public class Tftp
extends java.lang.Object

The TFTPClient bean is used to exchange files with TFTP servers via the TFTP protocol defined in RFC 783.

To use the bean, first specify the TFTPServer , then a LocalFile and a RemoteFile , and then call GetFile or PutFile . The Transfer event shows the progress of the transfer.

Potential transmission errors and packet loss are managed by the Timeout property which controls the maximum time to wait for a response from the server, and the MaxRetransmits property which specifies how many times to resend a failed packet before giving up.


Constructor Summary
Tftp()
          Creates an instance of Tftp Bean.
Tftp(java.lang.String runtimeLicense)
          Creates an instance of Tftp Bean with specified run-time license.
 
Method Summary
 void addTftpEventListener(TftpEventListener 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 getFile()
          Download a RemoteFile from the TFTP server.
 java.lang.String getLocalFile()
          The file on the local host to transfer the data to/from.
 java.lang.String getLocalHost()
          The name of the local host or user-assigned IP interface through which connections are initiated or accepted.
 int getMaxRetransmits()
          The number of times to retry sending a failed packet before disconnecting.
 java.lang.String getRemoteFile()
          The file on the remote host.
 int getRetransmitTimeout()
          Maximum time in seconds to wait for a reply packet from the server before retransmitting the last packet.
 int getTFTPPort()
          The UDP port where the remote TFTP server is listening.
 java.lang.String getTFTPServer()
          The address of the TFTP server to exchange files with.
 int getTimeout()
          A timeout for the bean.
 void interrupt()
          Interrupt the current method.
 boolean isIdle()
          The current status of the component.
 void putFile()
          Upload a file specified by LocalFile to the TFTP server.
 void removeTftpEventListener(TftpEventListener l)
           
 void setDownloadStream(java.io.OutputStream downloadStream)
          Sets the stream to which the downloaded data from the server will be written.
 void setLocalFile(java.lang.String localFile)
          The file on the local host to transfer the data to/from.
 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 setMaxRetransmits(int maxRetransmits)
          The number of times to retry sending a failed packet before disconnecting.
 void setRemoteFile(java.lang.String remoteFile)
          The file on the remote host.
 void setRetransmitTimeout(int retransmitTimeout)
          Maximum time in seconds to wait for a reply packet from the server before retransmitting the last packet.
 void setTFTPPort(int TFTPPort)
          The UDP port where the remote TFTP server is listening.
 void setTFTPServer(java.lang.String TFTPServer)
          The address of the TFTP server to exchange files with.
 void setTimeout(int timeout)
          A timeout for the bean.
 void setUploadStream(java.io.InputStream uploadStream)
          Sets the stream to be uploaded to the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tftp

public Tftp()
Creates an instance of Tftp Bean.


Tftp

public Tftp(java.lang.String runtimeLicense)
Creates an instance of Tftp 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.


getLocalFile

public java.lang.String getLocalFile()
The file on the local host to transfer the data to/from.

If GetFile is called, and LocalFile already exists, it is overwritten. If PutFile is called, LocalFile must point to a valid file, or an error will be returned.


setLocalFile

public void setLocalFile(java.lang.String localFile)
                  throws IPWorksException
The file on the local host to transfer the data to/from.

If GetFile is called, and LocalFile already exists, it is overwritten. If PutFile is called, LocalFile must point to a valid file, or an error will be returned.

Throws:
IPWorksException

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

getMaxRetransmits

public int getMaxRetransmits()
The number of times to retry sending a failed packet before disconnecting.

This property allows you to specify the number of times that you would like to try re-sending the last data packet if the original packet fails.

The RetransmitTimeout determines the wait time (in seconds) between successive retransmissions.

The default value for the MaxRetransmits property is 3.


setMaxRetransmits

public void setMaxRetransmits(int maxRetransmits)
                       throws IPWorksException
The number of times to retry sending a failed packet before disconnecting.

This property allows you to specify the number of times that you would like to try re-sending the last data packet if the original packet fails.

The RetransmitTimeout determines the wait time (in seconds) between successive retransmissions.

The default value for the MaxRetransmits property is 3.

Throws:
IPWorksException

getRemoteFile

public java.lang.String getRemoteFile()
The file on the remote host.

When the GetFile is called, this must be a valid file on the TFTPServer .


setRemoteFile

public void setRemoteFile(java.lang.String remoteFile)
                   throws IPWorksException
The file on the remote host.

When the GetFile is called, this must be a valid file on the TFTPServer .

Throws:
IPWorksException

getRetransmitTimeout

public int getRetransmitTimeout()
Maximum time in seconds to wait for a reply packet from the server before retransmitting the last packet.

Please refer to the MaxRetransmits property for the number of retransmit efforts before an error is returned.

The default value for the RetransmitTimeout is 5 seconds.


setRetransmitTimeout

public void setRetransmitTimeout(int retransmitTimeout)
                          throws IPWorksException
Maximum time in seconds to wait for a reply packet from the server before retransmitting the last packet.

Please refer to the MaxRetransmits property for the number of retransmit efforts before an error is returned.

The default value for the RetransmitTimeout is 5 seconds.

Throws:
IPWorksException

getTFTPPort

public int getTFTPPort()
The UDP port where the remote TFTP server is listening.

The TFTPPort is the UDP port on the TFTPServer to send TFTP requests to.


setTFTPPort

public void setTFTPPort(int TFTPPort)
                 throws IPWorksException
The UDP port where the remote TFTP server is listening.

The TFTPPort is the UDP port on the TFTPServer to send TFTP requests to.

Throws:
IPWorksException

getTFTPServer

public java.lang.String getTFTPServer()
The address of the TFTP server to exchange files with.

To be able to transfer file via TFTP, the remote host must be running TFTP services on port TFTPPort (default 69).

Example (Get a File)

 TFTPControl.TFTPServer = "MyServer"
 TFTPControl.LocalFile = "C:\\filename.txt"
 TFTPControl.RemoteFile = "/remotefile.txt"
 TFTPControl.GetFile() 


setTFTPServer

public void setTFTPServer(java.lang.String TFTPServer)
                   throws IPWorksException
The address of the TFTP server to exchange files with.

To be able to transfer file via TFTP, the remote host must be running TFTP services on port TFTPPort (default 69).

Example (Get a File)

 TFTPControl.TFTPServer = "MyServer"
 TFTPControl.LocalFile = "C:\\filename.txt"
 TFTPControl.RemoteFile = "/remotefile.txt"
 TFTPControl.GetFile() 

Throws:
IPWorksException

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

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.

TFTP Configuration Settings

TransferMode
Determines the transfer mode that will be used when transferring a file
Available modes:
Value
Description
0 (default)
Binary (Octet)
1
Ascii (Netascii)
CloseStreamAfterTransfer
If true, the component will close the upload or download stream after the transfer
This entry is for bean and all the components that descend from it.This property is true by default. Therefore, by default, all streams will be closed after a transfer is completed. In order to keep streams open after the transfer of data, you must set this config to false.

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

getFile

public void getFile()
             throws IPWorksException
Download a RemoteFile from the TFTP server.

The remote file specified by RemoteFile is downloaded to the local file specified by LocalFile , or it is retrieved through the Transfer event, if the LocalFile property is "" (empty string).

Example (Get a File)

 TFTPControl.TFTPServer = "MyServer"
 TFTPControl.LocalFile = "C:\\filename.txt"
 TFTPControl.RemoteFile = "/remotefile.txt"
 TFTPControl.GetFile() 

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

putFile

public void putFile()
             throws IPWorksException
Upload a file specified by LocalFile to the TFTP server.

The local file specified by LocalFile is uploaded to the remote file specified by RemoteFile .

Example (Put a File)

 TFTPControl.TFTPServer = "MyServer"
 TFTPControl.LocalFile = "C:\\filename.txt"
 TFTPControl.RemoteFile = "/remotefile.txt"
 TFTPControl.PutFile() 

Throws:
IPWorksException

setDownloadStream

public void setDownloadStream(java.io.OutputStream downloadStream)
                       throws IPWorksException
Sets the stream to which the downloaded data from the server will be written.

If a download stream is set before the GetFile method is called, the downloaded data will be written to the stream. The stream should be open and normally set to position 0. The bean will automatically close this stream if CloseStreamAfterTransfer is set to true (default). If the stream is closed, you will need to call SetDownloadStream again before calling GetFile again. The downloaded content will be written starting at the current position in the stream.

Note: SetDownloadStream and LocalFile will reset the other.

Throws:
IPWorksException

setUploadStream

public void setUploadStream(java.io.InputStream uploadStream)
                     throws IPWorksException
Sets the stream to be uploaded to the server.

If an upload stream is set before the PutFile method is called, the content of the stream will be read by the bean and uploaded to the server; The stream should be open and normally set to position 0. The bean will automatically close this stream if CloseStreamAfterTransfer is set to true (default). If the stream is closed, you will need to call SetUploadStream again before calling PutFile again. The content of the stream will be read from the current position all the way to the end.

Note: SetUploadStream and LocalFile will reset the other.

Throws:
IPWorksException

addTftpEventListener

public void addTftpEventListener(TftpEventListener l)
                          throws java.util.TooManyListenersException
Throws:
java.util.TooManyListenersException

removeTftpEventListener

public void removeTftpEventListener(TftpEventListener l)

IP*Works! V9

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