IP*Works!

ipworks
Class Tftp

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

public class Tftp
extends java.lang.Object

The TFTPClient control is used to exchange files with TFTP servers via the TFTP protocol.

To use the control, first specify the TFTPServer , then a LocalFile and a RemoteFile , and set the Action property to either tftpGetFile or tftpPutFile or call the equivalent methods. 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.


Field Summary
static int tftpGetFile
           
static int tftpIdle
           
static int tftpPutFile
           
 
Constructor Summary
Tftp()
           
 
Method Summary
 void addTftpEventListener(TftpEventListener l)
           
 void fireEndTransfer()
          Fired when a file completes downloading/uploading.
 void fireError(int errorCode, java.lang.String description)
          Information about errors during data delivery.
 void fireStartTransfer()
          Fired when a file starts downloading/uploading.
 void fireTransfer(int bytesTransferred, byte[] text)
          Fired during file download/upload.
 int getAction()
          An action code for the control.
 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 component.
 void interrupt()
          Interrupt the Action in progress (if any).
 void putFile()
          Upload a file specified by LocalFile to the TFTP server.
 void removeTftpEventListener(TftpEventListener l)
           
 void setAction(int action)
          An action code for the control.
 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 component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tftpIdle

public static final int tftpIdle

tftpGetFile

public static final int tftpGetFile

tftpPutFile

public static final int tftpPutFile
Constructor Detail

Tftp

public Tftp()
Method Detail

getAction

public int getAction()
An action code for the control. The following are the possible values for the Action property and the corresponding descriptions:
tftpIdle (0)
Default action. It can also be used to interrupt the current operation.
tftpGetFile (1)
A request is sent to the TFTPServer for the file specified by RemoteFile . If LocalFile points to a valid file, the data is received in LocalFile , otherwise the data is received through the through the Transfer event.
tftpPutFile (2)
A connection is made to the TFTPServer and the file specified by LocalFile is sent to RemoteFile in the TFTPServer .

After a successful transfer, the control returns control, and the Action property converts to tftpIdle .


setAction

public void setAction(int action)
               throws IPWorksException
An action code for the control. The following are the possible values for the Action property and the corresponding descriptions:
tftpIdle (0)
Default action. It can also be used to interrupt the current operation.
tftpGetFile (1)
A request is sent to the TFTPServer for the file specified by RemoteFile . If LocalFile points to a valid file, the data is received in LocalFile , otherwise the data is received through the through the Transfer event.
tftpPutFile (2)
A connection is made to the TFTPServer and the file specified by LocalFile is sent to RemoteFile in the TFTPServer .

After a successful transfer, the control returns control, and the Action property converts to tftpIdle .


getLocalFile

public java.lang.String getLocalFile()
The file on the local host to transfer the data to/from. If Action is tftpGetFile and the file already exists, it is overwritten. If Action is tftpPutFile , 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 Action is tftpGetFile and the file already exists, it is overwritten. If Action is tftpPutFile , LocalFile must point to a valid file, or an error will be returned.


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() Winsock 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 control initiate connections (or accept in the case of server controls) only through that interface.

If the control 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() Winsock 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 control initiate connections (or accept in the case of server controls) only through that interface.

If the control 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.


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.


getRemoteFile

public java.lang.String getRemoteFile()
The file on the remote host. When the Action is 'Get File', 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 Action is 'Get File', this must be a valid file on the TFTPServer .


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.


getTFTPPort

public int getTFTPPort()
The UDP port where the remote TFTP server is listening. The TFTPPort is the UDP port on the TFTPServer where 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 where to send TFTP requests to.


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).


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).


getTimeout

public int getTimeout()
A timeout for the component. If the Timeout property is set to 0 (default value) all actions will run uninterrupted until succesful completion, or an error condition is encountered.

If Timeout is set to a positive value, and any action does not complete within Timeout seconds, the action is aborted, and a 'Timeout' error is fired..

The control 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 always remains responsive.


setTimeout

public void setTimeout(int timeout)
                throws IPWorksException
A timeout for the component. If the Timeout property is set to 0 (default value) all actions will run uninterrupted until succesful completion, or an error condition is encountered.

If Timeout is set to a positive value, and any action does not complete within Timeout seconds, the action is aborted, and a 'Timeout' error is fired..

The control 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 always remains responsive.


fireEndTransfer

public void fireEndTransfer()
Fired when a file completes downloading/uploading. (Called internally to dispatch the event.)
See Also:
TftpEndTransferEvent

fireError

public void fireError(int errorCode,
                      java.lang.String description)
Information about errors during data delivery. (Called internally to dispatch the event.)
See Also:
TftpErrorEvent

fireStartTransfer

public void fireStartTransfer()
Fired when a file starts downloading/uploading. (Called internally to dispatch the event.)
See Also:
TftpStartTransferEvent

fireTransfer

public void fireTransfer(int bytesTransferred,
                         byte[] text)
Fired during file download/upload. (Called internally to dispatch the event.)
See Also:
TftpTransferEvent

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).

Calling this method is equivalent to setting the Action property to tftpGetFile .


interrupt

public void interrupt()
               throws IPWorksException
Interrupt the Action in progress (if any). Calling this method is equivalent to setting the Action property to Idle (0) .


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 .

Calling this method is equivalent to setting the Action property to tftpPutFile .


addTftpEventListener

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

removeTftpEventListener

public void removeTftpEventListener(TftpEventListener l)

IP*Works!

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