|
|||||||||
| Home >> All >> org >> apache >> commons >> net >> [ tftp overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.commons.net.tftp
Class TFTPClient

java.lang.Objectorg.apache.commons.net.DatagramSocketClient
org.apache.commons.net.tftp.TFTP
org.apache.commons.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 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() 55 , close() 55 , sendFile() 55 , and receiveFile() 55 methods. Additionally, the setMaxTimeouts() 55 and setDefaultTimeout() 55 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.
| Field Summary | |
private int |
__maxTimeouts
The maximum number of timeouts allowed before failing. |
static 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. |
| Fields inherited from class org.apache.commons.net.tftp.TFTP |
_sendBuffer, ASCII_MODE, BINARY_MODE, DEFAULT_PORT, DEFAULT_TIMEOUT, IMAGE_MODE, NETASCII_MODE, OCTET_MODE, PACKET_SIZE |
| Fields inherited from class org.apache.commons.net.DatagramSocketClient |
_isOpen_, _socket_, _socketFactory_, _timeout_ |
| Constructor Summary | |
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 Summary | |
int |
getMaxTimeouts()
Returns the maximum number of times a receive attempt is allowed to timeout before ending attempts to retry the receive and failing. |
int |
receiveFile(java.lang.String filename,
int mode,
java.io.OutputStream output,
java.net.InetAddress host)
Same as calling receiveFile(filename, mode, output, host, TFTP.DEFAULT_PORT). |
int |
receiveFile(java.lang.String filename,
int mode,
java.io.OutputStream output,
java.net.InetAddress host,
int port)
Requests a named file from a remote host, writes the file to an OutputStream, closes the connection, and returns the number of bytes read. |
int |
receiveFile(java.lang.String filename,
int mode,
java.io.OutputStream output,
java.lang.String hostname)
Same as calling receiveFile(filename, mode, output, hostname, TFTP.DEFAULT_PORT). |
int |
receiveFile(java.lang.String filename,
int mode,
java.io.OutputStream output,
java.lang.String hostname,
int port)
Requests a named file from a remote host, writes the file to an OutputStream, closes the connection, and returns the number of bytes read. |
void |
sendFile(java.lang.String filename,
int mode,
java.io.InputStream input,
java.net.InetAddress host)
Same as calling sendFile(filename, mode, input, host, TFTP.DEFAULT_PORT). |
void |
sendFile(java.lang.String filename,
int mode,
java.io.InputStream input,
java.net.InetAddress host,
int port)
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. |
void |
sendFile(java.lang.String filename,
int mode,
java.io.InputStream input,
java.lang.String hostname)
Same as calling sendFile(filename, mode, input, hostname, TFTP.DEFAULT_PORT). |
void |
sendFile(java.lang.String filename,
int mode,
java.io.InputStream input,
java.lang.String hostname,
int port)
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. |
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. |
| Methods inherited from class org.apache.commons.net.tftp.TFTP |
beginBufferedOps, bufferedReceive, bufferedSend, discardPackets, endBufferedOps, getModeName, receive, send |
| Methods inherited from class org.apache.commons.net.DatagramSocketClient |
close, getDefaultTimeout, getLocalAddress, getLocalPort, getSoTimeout, isOpen, open, open, open, setDatagramSocketFactory, setDefaultTimeout, setSoTimeout |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
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.
- See Also:
- Constant Field Values
__maxTimeouts
private int __maxTimeouts
- The maximum number of timeouts allowed before failing.
| Constructor Detail |
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.
| Method Detail |
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.
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.
receiveFile
public int receiveFile(java.lang.String filename, int mode, java.io.OutputStream output, java.net.InetAddress host, int port) throws java.io.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() 55 before
invoking this method. This method will not close the OutputStream
containing the file; you must close it after the method invocation.
receiveFile
public int receiveFile(java.lang.String filename, int mode, java.io.OutputStream output, java.lang.String hostname, int port) throws java.net.UnknownHostException, java.io.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() 55 before
invoking this method. This method will not close the OutputStream
containing the file; you must close it after the method invocation.
receiveFile
public int receiveFile(java.lang.String filename, int mode, java.io.OutputStream output, java.net.InetAddress host) throws java.io.IOException
- Same as calling receiveFile(filename, mode, output, host, TFTP.DEFAULT_PORT).
receiveFile
public int receiveFile(java.lang.String filename, int mode, java.io.OutputStream output, java.lang.String hostname) throws java.net.UnknownHostException, java.io.IOException
- Same as calling receiveFile(filename, mode, output, hostname, TFTP.DEFAULT_PORT).
sendFile
public void sendFile(java.lang.String filename, int mode, java.io.InputStream input, java.net.InetAddress host, int port) throws java.io.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() 55 before
invoking this method. This method will not close the InputStream
containing the file; you must close it after the method invocation.
sendFile
public void sendFile(java.lang.String filename, int mode, java.io.InputStream input, java.lang.String hostname, int port) throws java.net.UnknownHostException, java.io.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() 55 before
invoking this method. This method will not close the InputStream
containing the file; you must close it after the method invocation.
sendFile
public void sendFile(java.lang.String filename, int mode, java.io.InputStream input, java.net.InetAddress host) throws java.io.IOException
- Same as calling sendFile(filename, mode, input, host, TFTP.DEFAULT_PORT).
sendFile
public void sendFile(java.lang.String filename, int mode, java.io.InputStream input, java.lang.String hostname) throws java.net.UnknownHostException, java.io.IOException
- Same as calling sendFile(filename, mode, input, hostname, TFTP.DEFAULT_PORT).
|
|||||||||
| Home >> All >> org >> apache >> commons >> net >> [ tftp overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC