ORO, Inc. Logo  All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.oroinc.net.tftp.TFTPClient

java.lang.Object
   |
   +----com.oroinc.net.DatagramSocketClient
           |
           +----com.oroinc.net.tftp.TFTP
                   |
                   +----com.oroinc.net.tftp.TFTPClient

public class TFTPClient
extends TFTP
The TFTPClient class encapsulates all the aspects of the TFTP protocol necessary to receive and send files through TFTP. It is derived from the TFTP class because it is more convenient than using aggregation, and as a result exposes the same set of methods to allow you to deal with the TFTP protocol directly. However, almost every user should only be concerend with the the open() , close() , sendFile() , and receiveFile() methods. Additionally, the setMaxTimeouts() and setDefaultTimeout() methods may be of importance for performance tuning.

Details regarding the TFTP protocol and the format of TFTP packets can be found in RFC 783. But the point of these classes is to keep you from having to worry about the internals.

Copyright © 1997 Original Reusable Objects, Inc. All rights reserved.

See Also:
TFTP, TFTPPacket, TFTPPacketException

Variable Index

 o DEFAULT_MAX_TIMEOUTS
The default number of times a receive attempt is allowed to timeout before ending attempts to retry the receive and failing.

Constructor Index

 o TFTPClient()
Creates a TFTPClient instance with a default timeout of DEFAULT_TIMEOUT, maximum timeouts value of DEFAULT_MAX_TIMEOUTS, a null socket, and buffered operations disabled.

Method Index

 o getMaxTimeouts()
Returns the maximum number of times a receive attempt is allowed to timeout before ending attempts to retry the receive and failing.
 o receiveFile(String, int, OutputStream, InetAddress)
Same as calling receiveFile(filename, mode, output, host, TFTP.DEFAULT_PORT)

 o receiveFile(String, int, OutputStream, InetAddress, int)
Requests a named file from a remote host, writes the file to an OutputStream, closes the connection, and returns the number of bytes read.
 o receiveFile(String, int, OutputStream, String)
Same as calling receiveFile(filename, mode, output, hostname, TFTP.DEFAULT_PORT)

 o receiveFile(String, int, OutputStream, String, int)
Requests a named file from a remote host, writes the file to an OutputStream, closes the connection, and returns the number of bytes read.
 o sendFile(String, int, InputStream, InetAddress)
Same as calling sendFile(filename, mode, input, host, TFTP.DEFAULT_PORT);

 o sendFile(String, int, InputStream, InetAddress, int)
Requests to send a file to a remote host, reads the file from an InputStream, sends the file to the remote host, and closes the connection.
 o sendFile(String, int, InputStream, String)
Same as calling sendFile(filename, mode, input, hostname, TFTP.DEFAULT_PORT);

 o sendFile(String, int, InputStream, String, int)
Requests to send a file to a remote host, reads the file from an InputStream, sends the file to the remote host, and closes the connection.
 o setMaxTimeouts(int)
Sets the maximum number of times a receive attempt is allowed to timeout during a receiveFile() or sendFile() operation before ending attempts to retry the receive and failing.

Variables

 o DEFAULT_MAX_TIMEOUTS
 public static final int DEFAULT_MAX_TIMEOUTS
The default number of times a receive attempt is allowed to timeout before ending attempts to retry the receive and failing. The default is 5 timeouts.

Constructors

 o TFTPClient
 public TFTPClient()
Creates a TFTPClient instance with a default timeout of DEFAULT_TIMEOUT, maximum timeouts value of DEFAULT_MAX_TIMEOUTS, a null socket, and buffered operations disabled.

Methods

 o setMaxTimeouts
 public void setMaxTimeouts(int numTimeouts)
Sets the maximum number of times a receive attempt is allowed to timeout during a receiveFile() or sendFile() operation before ending attempts to retry the receive and failing. The default is DEFAULT_MAX_TIMEOUTS.

Parameters:
numTimeouts - The maximum number of timeouts to allow. Values less than 1 should not be used, but if they are, they are treated as 1.
 o getMaxTimeouts
 public int getMaxTimeouts()
Returns the maximum number of times a receive attempt is allowed to timeout before ending attempts to retry the receive and failing.

Returns:
The maximum number of timeouts allowed.
 o receiveFile
 public int receiveFile(String filename,
                        int mode,
                        OutputStream output,
                        InetAddress host,
                        int port) throws IOException
Requests a named file from a remote host, writes the file to an OutputStream, closes the connection, and returns the number of bytes read. A local UDP socket must first be created by open() before invoking this method. This method will not close the OutputStream containing the file; you must close it after the method invocation.

Parameters:
filename - The name of the file to receive.
mode - The TFTP mode of the transfer (one of the MODE constants).
output - The OutputStream to which the file should be written.
host - The remote host serving the file.
port - The port number of the remote TFTP server.
Throws: IOException
If an I/O error occurs. The nature of the error will be reported in the message.
 o receiveFile
 public int receiveFile(String filename,
                        int mode,
                        OutputStream output,
                        String hostname,
                        int port) throws UnknownHostException, IOException
Requests a named file from a remote host, writes the file to an OutputStream, closes the connection, and returns the number of bytes read. A local UDP socket must first be created by open() before invoking this method. This method will not close the OutputStream containing the file; you must close it after the method invocation.

Parameters:
filename - The name of the file to receive.
mode - The TFTP mode of the transfer (one of the MODE constants).
output - The OutputStream to which the file should be written.
hostname - The name of the remote host serving the file.
port - The port number of the remote TFTP server.
Throws: IOException
If an I/O error occurs. The nature of the error will be reported in the message.
Throws: UnknownHostException
If the hostname cannot be resolved.
 o receiveFile
 public int receiveFile(String filename,
                        int mode,
                        OutputStream output,
                        InetAddress host) throws IOException
Same as calling receiveFile(filename, mode, output, host, TFTP.DEFAULT_PORT)

Parameters:
filename - The name of the file to receive.
mode - The TFTP mode of the transfer (one of the MODE constants).
output - The OutputStream to which the file should be written.
host - The remote host serving the file.
Throws: IOException
If an I/O error occurs. The nature of the error will be reported in the message.
 o receiveFile
 public int receiveFile(String filename,
                        int mode,
                        OutputStream output,
                        String hostname) throws UnknownHostException, IOException
Same as calling receiveFile(filename, mode, output, hostname, TFTP.DEFAULT_PORT)

Parameters:
filename - The name of the file to receive.
mode - The TFTP mode of the transfer (one of the MODE constants).
output - The OutputStream to which the file should be written.
hostname - The name of the remote host serving the file.
Throws: IOException
If an I/O error occurs. The nature of the error will be reported in the message.
Throws: UnknownHostException
If the hostname cannot be resolved.
 o sendFile
 public void sendFile(String filename,
                      int mode,
                      InputStream input,
                      InetAddress host,
                      int port) throws IOException
Requests to send a file to a remote host, reads the file from an InputStream, sends the file to the remote host, and closes the connection. A local UDP socket must first be created by open() before invoking this method. This method will not close the InputStream containing the file; you must close it after the method invocation.

Parameters:
filename - The name the remote server should use when creating the file on its file system.
mode - The TFTP mode of the transfer (one of the MODE constants).
output - The InputStream containing the file.
host - The remote host receiving the file.
port - The port number of the remote TFTP server.
Throws: IOException
If an I/O error occurs. The nature of the error will be reported in the message.
 o sendFile
 public void sendFile(String filename,
                      int mode,
                      InputStream input,
                      String hostname,
                      int port) throws UnknownHostException, IOException
Requests to send a file to a remote host, reads the file from an InputStream, sends the file to the remote host, and closes the connection. A local UDP socket must first be created by open() before invoking this method. This method will not close the InputStream containing the file; you must close it after the method invocation.

Parameters:
filename - The name the remote server should use when creating the file on its file system.
mode - The TFTP mode of the transfer (one of the MODE constants).
output - The InputStream containing the file.
hostname - The name of the remote host receiving the file.
port - The port number of the remote TFTP server.
Throws: IOException
If an I/O error occurs. The nature of the error will be reported in the message.
Throws: UnknownHostException
If the hostname cannot be resolved.
 o sendFile
 public void sendFile(String filename,
                      int mode,
                      InputStream input,
                      InetAddress host) throws IOException
Same as calling sendFile(filename, mode, input, host, TFTP.DEFAULT_PORT);

Parameters:
filename - The name the remote server should use when creating the file on its file system.
mode - The TFTP mode of the transfer (one of the MODE constants).
output - The InputStream containing the file.
hostname - The name of the remote host receiving the file.
port - The port number of the remote TFTP server.
Throws: IOException
If an I/O error occurs. The nature of the error will be reported in the message.
Throws: UnknownHostException
If the hostname cannot be resolved.
 o sendFile
 public void sendFile(String filename,
                      int mode,
                      InputStream input,
                      String hostname) throws UnknownHostException, IOException
Same as calling sendFile(filename, mode, input, hostname, TFTP.DEFAULT_PORT);

Parameters:
filename - The name the remote server should use when creating the file on its file system.
mode - The TFTP mode of the transfer (one of the MODE constants).
output - The InputStream containing the file.
hostname - The name of the remote host receiving the file.
port - The port number of the remote TFTP server.
Throws: IOException
If an I/O error occurs. The nature of the error will be reported in the message.
Throws: UnknownHostException
If the hostname cannot be resolved.

ORO, Inc. Logo  All Packages  Class Hierarchy  This Package  Previous  Next  Index