|
IP*Works! V9 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectipworks.Ftp
public class Ftp
The FTP Bean can be used to transfer files to and from FTP servers using the FTP Protocol.
The FTP Bean implements a standard FTP client as specified in RFC 959 and RFC 1579.
The first step in using the bean is specifying the RemoteHost
, User
and Password
. The file to upload to or download from is
given by the RemoteFile
property. The file to download to or upload
from is specified by LocalFile
. The current path in the server is
specified by the RemotePath
property. The Passive
property is especially useful if the client is behind a firewall which inhibits
incoming connections to higher ports.
If LocalFile
is set to something
other than an empty string, then files are received in LocalFile
,
otherwise the data is received through the Transfer
event. StartTransfer
and EndTransfer
are fired at the beginning and end of transmission.
The PITrail
event traces the interaction between the client and the server
(the FTP Protocol Interface connection).
Directory listings are received through the DirList
event.
Field Summary | |
---|---|
static int |
tmASCII
|
static int |
tmBinary
|
static int |
tmDefault
|
Constructor Summary | |
---|---|
Ftp()
Creates an instance of Ftp Bean. |
|
Ftp(java.lang.String runtimeLicense)
Creates an instance of Ftp Bean with specified run-time license. |
Method Summary | |
---|---|
void |
abort()
Abort Current Upload/Download. |
void |
addFtpEventListener(FtpEventListener l)
|
void |
append()
Append data from LocalFile to a RemoteFile on an FTP server. |
java.lang.String |
config(java.lang.String configurationString)
Sets or retrieves a configuration setting. |
void |
deleteFile(java.lang.String fileName)
Remove a file specified by FileName from an FTP server. |
void |
doEvents()
Processes events from the internal message queue. |
void |
download()
Download a RemoteFile from an FTP server. |
java.lang.String |
getAccount()
The user account to login with. |
DirEntryList |
getDirList()
Collection of entries resulting in the last directory listing. |
long |
getFileSize()
The size of the file pointed to by RemoteFile . |
java.lang.String |
getFileTime()
The last modification time of the file pointed to by RemoteFile . |
Firewall |
getFirewall()
A set of properties related to firewall access. |
java.lang.String |
getLastReply()
The last reply from the server. |
java.lang.String |
getLocalFile()
The path to a local file for download/upload. |
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 |
getPassword()
The password to log in. |
java.lang.String |
getRemoteFile()
The name of the remote file for uploading, downloading, etc. |
java.lang.String |
getRemoteHost()
The domain name or IP address of the FTP server. |
java.lang.String |
getRemotePath()
The current path in the FTP server. |
int |
getRemotePort()
The port for the FTP service (default is 21). |
java.lang.String |
getStartByte()
The byte index in RemoteFile and LocalFile from which to start the transmission. |
int |
getTimeout()
A timeout for the bean. |
int |
getTransferMode()
The transfer mode (ASCII or Binary). |
java.lang.String |
getUser()
The user identifier to use for login. |
void |
interrupt()
Interrupt the current method. |
boolean |
isConnected()
Shows whether the bean is connected. |
boolean |
isFileExists()
Returns True if the file specified by RemoteFile exists on the remote server. |
boolean |
isIdle()
The current status of the component. |
boolean |
isOverwrite()
Indicates whether or not the bean should overwrite files during transfer. |
boolean |
isPassive()
Controls whether to direct the server into passive mode. |
void |
listDirectory()
List the current directory specified by RemotePath on an FTP server. |
void |
listDirectoryLong()
List extended directory information for RemotePath . |
void |
logoff()
Logoff from the FTP server by posting a QUIT command. |
void |
logon()
Logon to the FTP RemoteHost using the current User and Password . |
void |
makeDirectory(java.lang.String newDir)
Create a directory on an FTP server. |
void |
removeDirectory(java.lang.String dirName)
Remove a directory specified by DirName from an FTP server. |
void |
removeFtpEventListener(FtpEventListener l)
|
void |
renameFile(java.lang.String newName)
Change the name of RemoteFile to NewName . |
void |
setAccount(java.lang.String account)
The user account to login with. |
void |
setCommand(java.lang.String command)
Used to send additional commands directly to the server. |
void |
setConnected(boolean connected)
Shows whether the bean is connected. |
void |
setDownloadStream(java.io.OutputStream downloadStream)
Sets the stream to which the downloaded data from the server will be written. |
void |
setFirewall(Firewall firewall)
A set of properties related to firewall access. |
void |
setLocalFile(java.lang.String localFile)
The path to a local file for download/upload. |
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 |
setOverwrite(boolean overwrite)
Indicates whether or not the bean should overwrite files during transfer. |
void |
setPassive(boolean passive)
Controls whether to direct the server into passive mode. |
void |
setPassword(java.lang.String password)
The password to log in. |
void |
setRemoteFile(java.lang.String remoteFile)
The name of the remote file for uploading, downloading, etc. |
void |
setRemoteHost(java.lang.String remoteHost)
The domain name or IP address of the FTP server. |
void |
setRemotePath(java.lang.String remotePath)
The current path in the FTP server. |
void |
setRemotePort(int remotePort)
The port for the FTP service (default is 21). |
void |
setStartByte(java.lang.String startByte)
The byte index in RemoteFile and LocalFile from which to start the transmission. |
void |
setTimeout(int timeout)
A timeout for the bean. |
void |
setTransferMode(int transferMode)
The transfer mode (ASCII or Binary). |
void |
setUploadStream(java.io.InputStream uploadStream)
Sets the stream from which the bean will read data to upload to the server. |
void |
setUser(java.lang.String user)
The user identifier to use for login. |
void |
storeUnique()
Upload a file with a Unique Name to an FTP server. |
void |
upload()
Upload a file specified by LocalFile to an FTP server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int tmDefault
public static final int tmASCII
public static final int tmBinary
Constructor Detail |
---|
public Ftp()
public Ftp(java.lang.String runtimeLicense)
Method Detail |
---|
public java.lang.String getAccount()
This property contains the user account to use when logging in. Some servers may require an Account
in order to Logon
or in order to access specific privileges, like uploading or deleting files.
public void setAccount(java.lang.String account) throws IPWorksException
This property contains the user account to use when logging in. Some servers may require an Account
in order to Logon
or in order to access specific privileges, like uploading or deleting files.
IPWorksException
public void setCommand(java.lang.String command) throws IPWorksException
This property can be used to send additional commands directly to the server. Check the LastReply
property and/or trap the PITrail
events
coming from the server to get the response.
IPWorksException
public boolean isConnected()
This property is used to determine whether or not the bean is connected to the remote host.
public void setConnected(boolean connected) throws IPWorksException
This property is used to determine whether or not the bean is connected to the remote host.
IPWorksException
public DirEntryList getDirList()
This property contains the collection of entries resulting in the last directory listing. A collection is returned after a response is received from the server after a call to either ListDirectory
or ListDirectoryLong
. The collection is made up of entries for each listing in the current directory, specified by the RemotePath
property.
MaxDirEntries
can be used to control the number of directory listings saved.
This collection is indexed from 0 to size - 1.
public boolean isFileExists()
RemoteFile
exists on the remote server.
This property returns True if the file exists on the remote server. It returns false if the file does not exist. You must specify the file you wish to check by setting the RemoteFile
prior to calling this method.
If the bean is busy or is not connected, 0 is returned.
If there is no FTP session in place, one is automatically created by first calling the Logon
method.
public long getFileSize()
RemoteFile
.
When this property is read, the FTP server is queried for the file size, and the response is provided as the property value.
If the bean is busy or is not connected, 0 is returned.
public java.lang.String getFileTime()
RemoteFile
.
When this property is read, the FTP server is queried for the file modification time, and the response is provided as the property value.
If the bean is busy or is not connected, an empty string is returned.
public Firewall getFirewall()
This is a Firewall
type property which
contains fields describing the firewall
through which the bean will attempt to connect.
public void setFirewall(Firewall firewall) throws IPWorksException
This is a Firewall
type property which
contains fields describing the firewall
through which the bean will attempt to connect.
IPWorksException
public boolean isIdle()
Idle
will be False if the component is currently busy (communicating
and/or waiting for an answer), and True at all other times.
public java.lang.String getLastReply()
This property indicates the last reply received from the server. It
can be used for informational purposes. The same information
and more can also be retrieved through the PITrail
event.
public java.lang.String getLocalFile()
This property is used by the Upload
and Download
methods to specify the path to a local file to be downloaded/uploaded. See the method descriptions for more information.
Example (Setting LocalFile)
FTPControl.Localfile = "C:\\localfile.txt"
FTPControl.RemoteFile = "remotefile.txt"
FTPControl.Download()
FTPControl.Localfile = "C:\\localfile2.txt"
FTPControl.RemoteFile = "folder/remotefile2.txt"
FTPControl.Download()
public void setLocalFile(java.lang.String localFile) throws IPWorksException
This property is used by the Upload
and Download
methods to specify the path to a local file to be downloaded/uploaded. See the method descriptions for more information.
Example (Setting LocalFile)
FTPControl.Localfile = "C:\\localfile.txt"
FTPControl.RemoteFile = "remotefile.txt"
FTPControl.Download()
FTPControl.Localfile = "C:\\localfile2.txt"
FTPControl.RemoteFile = "folder/remotefile2.txt"
FTPControl.Download()
IPWorksException
public java.lang.String getLocalHost()
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.
public void setLocalHost(java.lang.String localHost) throws IPWorksException
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.
IPWorksException
public boolean isOverwrite()
This property is a value indicating whether or not the bean should overwrite downloaded files. If Overwrite
is false, an error will be thrown whenever LocalFile
exists before a download operation.
public void setOverwrite(boolean overwrite) throws IPWorksException
This property is a value indicating whether or not the bean should overwrite downloaded files. If Overwrite
is false, an error will be thrown whenever LocalFile
exists before a download operation.
IPWorksException
public boolean isPassive()
This property controls whether to direct the server into passive mode. Many firewalls will not allow the FTP server to open a connection from outside to the higher ports where the FTP client bean expects them. If Passive is set to TRUE , the bean will use the PASV instead of the PORT command and will thus direct the server into passive mode: connections are initiated only by the client.
public void setPassive(boolean passive) throws IPWorksException
This property controls whether to direct the server into passive mode. Many firewalls will not allow the FTP server to open a connection from outside to the higher ports where the FTP client bean expects them. If Passive is set to TRUE , the bean will use the PASV instead of the PORT command and will thus direct the server into passive mode: connections are initiated only by the client.
IPWorksException
public java.lang.String getPassword()
This property contains the password used to log in and must be set before the bean connects to the FTP server.
public void setPassword(java.lang.String password) throws IPWorksException
This property contains the password used to log in and must be set before the bean connects to the FTP server.
IPWorksException
public java.lang.String getRemoteFile()
This property contains the name of the remote file to upload, download, etc. and is either an absolute file path, or a relative path based on RemotePath
.
A number of methods use RemoteFile
as an argument.
Example (Setting RemoteFile)
FTPControl.Localfile = "C:\\localfile.txt"
FTPControl.RemoteFile = "remotefile.txt"
FTPControl.Download()
FTPControl.Localfile = "C:\\localfile2.txt"
FTPControl.RemoteFile = "folder/remotefile2.txt"
FTPControl.Download()
Note: This property will also act as a file mask when performing ListDirectory
or ListDirectoryLong
.
Example (Using RemoteFile as a file mask):
FTPControl.RemoteFile = "*.txt"
FTPControl.ListDirectory()
The RemoteFile
property supports several pattern matching characters. The
following special characters are supported for pattern matching:
If the above characters need to be used as a literal in a FileMask then they must be escaped by surrounding them with a []. (Note, "]" and "-" do not need to be escaped) See below for the escape sequences:
For example, if you wanted to download a file whose name was [Something].txt
you could set the RemoteFile
property to: [[]Something].txt
public void setRemoteFile(java.lang.String remoteFile) throws IPWorksException
This property contains the name of the remote file to upload, download, etc. and is either an absolute file path, or a relative path based on RemotePath
.
A number of methods use RemoteFile
as an argument.
Example (Setting RemoteFile)
FTPControl.Localfile = "C:\\localfile.txt"
FTPControl.RemoteFile = "remotefile.txt"
FTPControl.Download()
FTPControl.Localfile = "C:\\localfile2.txt"
FTPControl.RemoteFile = "folder/remotefile2.txt"
FTPControl.Download()
Note: This property will also act as a file mask when performing ListDirectory
or ListDirectoryLong
.
Example (Using RemoteFile as a file mask):
FTPControl.RemoteFile = "*.txt"
FTPControl.ListDirectory()
The RemoteFile
property supports several pattern matching characters. The
following special characters are supported for pattern matching:
If the above characters need to be used as a literal in a FileMask then they must be escaped by surrounding them with a []. (Note, "]" and "-" do not need to be escaped) See below for the escape sequences:
For example, if you wanted to download a file whose name was [Something].txt
you could set the RemoteFile
property to: [[]Something].txt
IPWorksException
public java.lang.String getRemoteHost()
This property specifies the IP address (IP number in dotted internet format) or Domain Name of the FTP server. It is set before a connection is attempted and cannot be changed once a connection is in progress.
If this property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, this property is set to the corresponding address. If the search is not successful, an error is returned.
If the bean is configured to use a SOCKS firewall, the value assigned to this property may be preceded with an "*". If this is the case, the host name is passed to the firewall unresolved and the firewall performs the DNS resolution.
public void setRemoteHost(java.lang.String remoteHost) throws IPWorksException
This property specifies the IP address (IP number in dotted internet format) or Domain Name of the FTP server. It is set before a connection is attempted and cannot be changed once a connection is in progress.
If this property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, this property is set to the corresponding address. If the search is not successful, an error is returned.
If the bean is configured to use a SOCKS firewall, the value assigned to this property may be preceded with an "*". If this is the case, the host name is passed to the firewall unresolved and the firewall performs the DNS resolution.
IPWorksException
public java.lang.String getRemotePath()
This property shows the current working directory on the FTP server. It can also be used to change the working directory by setting it to an absolute directory path, or a relative path with respect to the existing value of this property.
If the first two bytes of the new path are "..", then a change to one level above in the directory tree is performed.
Setting this property causes the bean to send the appropriate command to the remote server only if connected.
Example (Changing Directory)
FTPControl.Logon()
FTPControl.RemotePath = "/home/user"
public void setRemotePath(java.lang.String remotePath) throws IPWorksException
This property shows the current working directory on the FTP server. It can also be used to change the working directory by setting it to an absolute directory path, or a relative path with respect to the existing value of this property.
If the first two bytes of the new path are "..", then a change to one level above in the directory tree is performed.
Setting this property causes the bean to send the appropriate command to the remote server only if connected.
Example (Changing Directory)
FTPControl.Logon()
FTPControl.RemotePath = "/home/user"
IPWorksException
public int getRemotePort()
This property contains the port for the FTP service, which defaults to 21 if not set. A valid port number (a value between 1 and 65535) is required for the connection to take place. The property must be set before a connection is attempted and cannot be changed once a connection is established. Any attempt to change this property while connected will fail with an error.
public void setRemotePort(int remotePort) throws IPWorksException
This property contains the port for the FTP service, which defaults to 21 if not set. A valid port number (a value between 1 and 65535) is required for the connection to take place. The property must be set before a connection is attempted and cannot be changed once a connection is established. Any attempt to change this property while connected will fail with an error.
IPWorksException
public java.lang.String getStartByte()
RemoteFile
and LocalFile
from which to start the transmission.
This property contains a zero-based index in both RemoteFile
and LocalFile
that determines the point where the transmission of data starts from. This is useful for resuming interrupted downloads and uploads of files from FTP servers.
Once set, the StartByte
index is used for all future downloads/uploads. The property must be reset to "0" for normal downloads/uploads.
The type of the property is a string instead of numeric to allow for certain implementations that expect an alphanumeric marker of the start index.
In the Transfer
event, the TransferredBytes parameter will include the bytes skipped (i.e. it will show StartByte
more bytes than actually transferred).
NOTE: some FTP servers may not support the FTP 'REST' command. If that is the case with the server you are accessing, you will not be able to use the StartByte
property.
public void setStartByte(java.lang.String startByte) throws IPWorksException
RemoteFile
and LocalFile
from which to start the transmission.
This property contains a zero-based index in both RemoteFile
and LocalFile
that determines the point where the transmission of data starts from. This is useful for resuming interrupted downloads and uploads of files from FTP servers.
Once set, the StartByte
index is used for all future downloads/uploads. The property must be reset to "0" for normal downloads/uploads.
The type of the property is a string instead of numeric to allow for certain implementations that expect an alphanumeric marker of the start index.
In the Transfer
event, the TransferredBytes parameter will include the bytes skipped (i.e. it will show StartByte
more bytes than actually transferred).
NOTE: some FTP servers may not support the FTP 'REST' command. If that is the case with the server you are accessing, you will not be able to use the StartByte
property.
IPWorksException
public int getTimeout()
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).
public void setTimeout(int timeout) throws IPWorksException
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).
IPWorksException
public int getTransferMode()
This property specifies the transfer mode, either ASCII or binary. The valid options for the TransferMode
property are as follows:
public void setTransferMode(int transferMode) throws IPWorksException
This property specifies the transfer mode, either ASCII or binary. The valid options for the TransferMode
property are as follows:
IPWorksException
public java.lang.String getUser()
This property contains the user identifier to be used when logging in and must be set before the bean connects to the FTP server.
public void setUser(java.lang.String user) throws IPWorksException
This property contains the user identifier to be used when logging in and must be set before the bean connects to the FTP server.
IPWorksException
public void abort() throws IPWorksException
This method sends an ABOR command to the FTP server. It is used to interrupt file uploads/downloads.
IPWorksException
public void append() throws IPWorksException
LocalFile
to a RemoteFile
on an FTP server.
This method causes the server-DTP to accept the data transferred via the data connection and to store the data in a file on the server site. If the file specified in the pathname exists on the server site, then the data shall be appended to that file; otherwise the file specified in the
pathname shall be created on the server site.
Similar to the Upload
method but the local file specified by LocalFile
is appended to RemoteFile
on the server as opposed to replacing it as done by the Upload
method. RemoteFile
is either an absolute path on the server, or a path relative to RemotePath
.
The server will create a file with that name if it doesn't already exist (similar to Upload).
If there is no FTP session in place, one is automatically created by first calling the Logon
method.
IPWorksException
public java.lang.String config(java.lang.String configurationString) throws IPWorksException
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.
Passive
= False) with a firewall, it may sometimes be necessary to specify the actual PORT value to be sent to the server. ActiveModePORTAddress
takes the protocol-level parameter in the form "a,b,c,d,e,f" where "a,b,c,d" is the external IP address separated by commas, and e and f represent, respectively, the high byte (divide by 256) and the low byte (mod 256) values of the external port where the FTP client is listening.This config must be used in conjunction with PortRange
to ensure that the correct port is used by the client.
LocalFile
.DirList
.
You can then use this property to define a regular expression to parse the entry. The value of this setting is specified in the following format: A,B,C,X=Y|RegEx
A,B,C, and X represent integer values that correspond to the capturing groups of the regular expression in the following order:
Since group X represents the IsDir value, the user must specify Y to indicate what value that group must have in order for IsDir to be true.
Take for instance a simple entry in this format:
22 Test.txt
In this example "22" is the FileSize and "Test.txt" is the FileName. In order to parse this entry we will define the DirEntryPattern as: 2,1,-1,-1|([0-9]+)\\s(.*)
The first value "2" indicates that the first field (FileName) corresponds to the second capturing group in the regular expression.
The second value "1" indicates that the second field (FileSize) corresponds to the first capturing group in the regular expression.
The capturing group is the regular expression in parenthesis. In the above example, the first capturing group is ([0-9]+) and the second
capturing group is (.*).
As seen in the above example -1 can also be specified as the integer value. When this is specified that field is ignored.
DILingerTime
is 0 (default), the
system will attempt to send pending data for a connection until the default
IP protocol timeout expires.
In the second scenario, DILingerTime
is a positive value, the system will
attempt to send pending data until the specified DILingerTime
is reached.
If this attempt fails, then the system will reset the connection.
The default behavior (which is also the default mode for stream sockets) might result in a long delay in closing the connection. Although the bean returns control immediately, the system could hold system resources until all pending data is sent (even after your application closes).
Setting this property to False forces an immediate disconnection. If you know that the other side has received all the data you sent (by a client acknowledgment, for example), setting this property to False might be the appropriate course of action.
FileTime
property.
To disable all formatting set this to empty string.Note: This setting only applies to the FileTime
property. It does not apply to the FileTime parameter of the DirList
event.
DirList
collection
after a call to either ListDirectory
or ListDirectoryLong
. This value
represents the number of entries that are to be saved in the collection
.To save all items to the collection
, set this config to -1. If no
items are wanted, set this to 0, which will not save any to the
collection
. The default for this config is -1, so all items will
be included in the collection
.
NOTE: This functionality is only available in Java and .NET.
Passive
= False), the bean uses any available port
to listen to incoming connections from the server. You can override this behavior by setting PortRange
to a value containing the range of ports the bean will be
listening to.The range is provided as start-end , for instance: "1024-" stands for anything higher
than 1024, "1024-2048" stands for ports between 1024 and 2048 inclusive, "4000-4010, 50000-50010"
stands for ports between 4000 and 4010 or between 50000 and 50010.
LocalFile
and continue monitoring LocalFile
for additional data to upload until no new data is found
for RealTimeUploadAgeLimit
seconds. This allows you to start uploading a file immediately after
the file is created and continue uploading as data is written to the file. The default value is "False".RealTimeUpload
is set to "True". This specifies
the number of seconds for which the bean will monitor LocalFile
for new data to upload. If this limit
is reached and no new data is found in LocalFile
the upload will complete. The default value is "1".RemoteFile
to the filemask and call either ListDirectory
or ListDirectoryLong
.
There is no difference between the two methods when this setting is enabled.
UseMLSD
except that it is only valid for a single file.
When this is set to True the bean will list the file or folder specified by RemoteFile
. If RemoteFile
is not set, a listing for the current directory itself will be returned. This command is an extension
to the protocol which defines a more standardized and reliable directory listing format, but for a single file or folder only.
Not all servers support this command. The default value is False.When set to True, set RemoteFile
to the file or folder you wish to get information about and call either ListDirectory
or ListDirectoryLong
.
There is no difference between the two methods when this setting is enabled. When both UseMLSD
and UseMLST
are set, UseMLSD
takes precedence.
UseModeZ
is set to True.Passive
is true. When this config is
set to false, the bean parses the remote host to send replies to
from the previous response from the server. If this config is
true (default), the bean uses the value at RemoteHost
instead.
FirewallHost
is given, requested connections will be authenticated through the specified firewall
when connecting.If the FirewallHost
setting is set to a Domain Name, a DNS request is initiated. Upon successful termination
of the request, the FirewallHost
setting is set to the corresponding address. If the search is not successful,
an error is returned.
NOTE: This is the same as Host . This setting is provided for use by beans that do not directly expose Firewall properties.
RemoteHost
and RemotePort
are used to tell the SOCKS firewall
in which address and port to listen to. The firewall rules may ignore RemoteHost
, and it is recommended that RemoteHost
be set to empty string in this case.
RemotePort
is the port in which the firewall will listen to. If set to 0, the firewall will select a random port. The
binding (address and port) is provided through the ConnectionStatus
event.
The connection to the firewall is made by calling the Connect
method.
FirewallHost
is specified, the FirewallUser
and FirewallPassword
settings
are used to connect and authenticate to the given firewall. If the authentication fails, the bean throws an exception.NOTE: This is the same as Password . This setting is provided for use by beans that do not directly expose Firewall properties.
FirewallPort
is set automatically when FirewallType
is set to a valid value.NOTE: This is the same as Port . This setting is provided for use by beans that do not directly expose Firewall properties.
FirewallPort
is set to 80.
FirewallPort
is set to 1080.
FirewallPort
is set to 1080.
FirewallHost
is specified, the FirewallUser
and FirewallPassword
settings are used to connect and authenticate to the Firewall. If the authentication fails, the bean throws an exception.NOTE: This is the same as User . This setting is provided for use by beans that do not directly expose Firewall properties.
TCPKeepAlive
will automatically be set to true.
By default the operating system will determine the
time a connection is idle before a TCP keep-alive packet is sent. This system default if this value is not specified here is 2 hours. In many
cases a shorter interval is more useful. Set this value to the desired interval in milliseconds.Note: This value is not applicable in Java.
TCPKeepAlive
will automatically be set to true.
A TCP keep-alive packet will be sent after a period of inactivity as
defined by KeepAliveTime
. If no acknowledgement is received from the remote host the keep-alive packet
will be re-sent. This setting specifies the interval at which the successive keep-alive packets are sent in milliseconds.
This system default if this value is not specified here is 1 second.Note: This value is not applicable in Java or MAC.
LingerTime
is 0 (default), the
system will attempt to send pending data for a connection until the default
IP protocol timeout expires.
In the second scenario, LingerTime
is a positive value, the system will
attempt to send pending data until the specified LingerTime
is reached.
If this attempt fails, then the system will reset the connection.
The default behavior (which is also the default mode for stream sockets) might result in a long delay in closing the connection. Although the bean returns control immediately, the system could hold system resources until all pending data is sent (even after your application closes).
Setting this property to False forces an immediate disconnection. If you know that the other side has received all the data you sent (by a client acknowledgment, for example), setting this property to False might be the appropriate course of action.
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
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.
MaxLineLength
is the size of an internal buffer, which holds received data while waiting for an EOL
string.If an EOL
string is found in the input stream before MaxLineLength
bytes are received, the DataIn
event is fired with the EOL parameter set to True, and the buffer is reset.
If no EOL
is found, and MaxLineLength
bytes are accumulated in the buffer, the DataIn
event is
fired with the EOL parameter set to False, and the buffer is reset.
The minimum value for MaxLineLength
is 256 bytes. The default value is 2048 bytes. The maximum value is 65536 bytes.
KeepAliveTime
and KeepAliveInterval
to
configure the timing of the keep-alive packets.Note: This value is not applicable in Java.
IPWorksException
public void deleteFile(java.lang.String fileName) throws IPWorksException
This method is used to remove a file specified by FileName from an FTP server. The remote file or directory specified by FileName is deleted. FileName is either an absolute path on the server, or a path relative to RemotePath
.
If there is no FTP session in place, one is automatically created by first calling the Logon
method.
IPWorksException
public void doEvents() throws IPWorksException
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.
IPWorksException
public void download() throws IPWorksException
RemoteFile
from an FTP server.
This method is used to download the remote file specified by RemoteFile
to the local file specified by LocalFile
, or it is retrieved through the Transfer
event. If the LocalFile
property is "" (empty string). RemoteFile
is either an absolute path on the server, or a path relative to RemotePath
.
If there is no FTP session in place, one is automatically created by first calling the Logon
method.
Example (Download a File)
FTPControl.Localfile = "C:\\localfile.txt"
FTPControl.RemoteFile = "remotefile.txt"
FTPControl.Download()
FTPControl.Localfile = "C:\\localfile2.txt"
FTPControl.RemoteFile = "folder/remotefile2.txt"
FTPControl.Download()
IPWorksException
public void interrupt() throws IPWorksException
If there is no method in progress, Interrupt
simply returns, doing nothing.
IPWorksException
public void listDirectory() throws IPWorksException
RemotePath
on an FTP server.
This method is used to list the directory (or file mask) specified in RemoteFile
. RemoteFile
is either an absolute path on the server, or a path relative to RemotePath
.
The file listing is received through the DirList
event.
Similar to ListDirectoryLong
, except only file names are returned.
Note that since RemoteFile
acts as a file mask, to retrieve a complete directory listing RemoteFile
should be set to empty string or a mask like "*".
If there is no FTP session in place, one is automatically created by first calling the Logon
method.
IPWorksException
public void listDirectoryLong() throws IPWorksException
RemotePath
.
This method is used to request a directory (or file mask) listing specified in RemoteFile
. RemoteFile
is either an absolute path on the server, or a path relative to RemotePath
.
The file listing is received through the DirList
event. Extended file information is returned.
Note that since RemoteFile
acts as a file mask, to retrieve a complete directory listing RemoteFile
should be set to empty string or a mask like "*".
If there is no FTP session in place, one is automatically created by first calling the Logon
method.
IPWorksException
public void logoff() throws IPWorksException
This method is used to logoff from the FTP server by posting a QUIT command. If that fails, the connection is terminated by the local host.
IPWorksException
public void logon() throws IPWorksException
RemoteHost
using the current User
and Password
.
This method is used to logon to the FTP server using the current User
and Password
. If TransferMode
is not 0 (Default), then the FTP transfer mode is set to the appropriate value.
Example (Logging On)
FTPControl.RemoteHost = "ftpserver"
FTPControl.User = "username"
FTPControl.Password = "password"
FTPControl.Logon()
IPWorksException
public void makeDirectory(java.lang.String newDir) throws IPWorksException
This method is used to create a directory with path specified by NewDir on the FTP server. NewDir is either an absolute path on the server, or a path relative to RemotePath
.
If there is no FTP session in place, one is automatically created by first calling the Logon
method.
IPWorksException
public void removeDirectory(java.lang.String dirName) throws IPWorksException
This property is used to remove a directory with path specified by DirName from the FTP server. DirName is either an absolute path on the server, or a path relative to RemotePath
.
If there is no FTP session in place, one is automatically created by first calling the Logon
method.
IPWorksException
public void renameFile(java.lang.String newName) throws IPWorksException
RemoteFile
to NewName .
This property is used to change the name of a remote file, specified by RemoteFile
to NewName . RemoteFile
and NewName are either absolute paths on the server, or a path relative to RemotePath
.
If there is no FTP session in place, one is automatically created by first calling the Logon
method.
IPWorksException
public void setDownloadStream(java.io.OutputStream downloadStream) throws IPWorksException
This method is used to set the stream to which the downloaded data from the server will be written. If a download stream is set before the Download
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 true (default).
If the stream is closed, you will need to call SetDownloadStream
again before calling Download
again.
The downloaded content will be written starting at the current position in the stream.
If StartByte
is non zero the server will be instructed to skip those bytes before starting to send the content of the file so it is up to you to build the stream appropriately in that case.
Note: SetDownloadStream
and LocalFile
will reset the other.
IPWorksException
public void setUploadStream(java.io.InputStream uploadStream) throws IPWorksException
This method is used to set the stream from which the bean will read data to upload to the server. If an upload stream is set before the Upload
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 true (default). If the stream is closed, you will need to call SetUploadStream
again before calling Upload
again.
The content of the stream will be read from the current position all the way to the end and no bytes will be skipped even if StartByte
is set to a non zero value (though the server will be instructed to skip those bytes in its file).
Note: SetUploadStream
and LocalFile
will reset the other.
IPWorksException
public void storeUnique() throws IPWorksException
This method is used to upload a file with a Unique Name to an FTP server. Similar to the Upload
method but the server determines a unique name for the LocalFile
to be saved on the current directory given by RemotePath
. The server includes the new name of the file in its response. The user should check the PITrail
event, or LastReply
property to retrieve this generated filename.
IPWorksException
public void upload() throws IPWorksException
LocalFile
to an FTP server.
This method uploads a local file specified by LocalFile
to the remote file specified by RemoteFile
. RemoteFile
is either an absolute path on the server, or a path relative to RemotePath
.
If there is no FTP session in place, one is automatically created by first calling the Logon
method.
If you want to append to a server file, please refer to the Append
method.
Example (Upload a File)
FTPControl.Localfile = "C:\\localfile.txt"
FTPControl.RemoteFile = "remotefile.txt"
FTPControl.Upload()
FTPControl.Localfile = "C:\\localfile2.txt"
FTPControl.RemoteFile = "folder/remotefile2.txt"
FTPControl.Upload()
IPWorksException
public void addFtpEventListener(FtpEventListener l) throws java.util.TooManyListenersException
java.util.TooManyListenersException
public void removeFtpEventListener(FtpEventListener l)
|
IP*Works! V9 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |