|
IP*Works! V9 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectipworks.Rcp
public class Rcp
The RCP bean implements the popular UNIX Remote Copy Protocol, used to transfer files between systems.
Using the bean is as simple as specifying a LocalFile
,
a RemoteFile
and RemoteHost
, and calling the GetFile
or the PutFile
method.
The Remote Copy Protocol is implemented over either RSHELL or
REXEC. The bean allows you to choose which protocol to use
via the Protocol
property.
Field Summary | |
---|---|
static int |
protRexec
|
static int |
protRshell
|
Constructor Summary | |
---|---|
Rcp()
Creates an instance of Rcp Bean. |
|
Rcp(java.lang.String runtimeLicense)
Creates an instance of Rcp Bean with specified run-time license. |
Method Summary | |
---|---|
void |
addRcpEventListener(RcpEventListener 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()
Gets the specified file. |
java.lang.String |
getFileMode()
The file mode for the RemoteFile . |
Firewall |
getFirewall()
A set of properties related to firewall access. |
java.lang.String |
getLocalFile()
The file on the local host. |
java.lang.String |
getLocalHost()
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. |
int |
getLocalPort()
The TCP port in the local host where the bean binds. |
java.lang.String |
getPassword()
The password associated with User . |
int |
getProtocol()
Sets the protocol to use for the transfer. |
java.lang.String |
getRemoteFile()
The file on the remote host. |
java.lang.String |
getRemoteHost()
The remote host to which to connect. |
int |
getRemotePort()
The port for the service (REXEC or RSHELL). |
int |
getTimeout()
A timeout for the bean. |
java.lang.String |
getUser()
The identification of the remote user for a transfer. |
void |
interrupt()
Interrupt the current method. |
boolean |
isIdle()
The current status of the component. |
void |
putFile()
Puts a file to a specified location. |
void |
removeRcpEventListener(RcpEventListener l)
|
void |
setFileMode(java.lang.String fileMode)
The file mode for the RemoteFile . |
void |
setFirewall(Firewall firewall)
A set of properties related to firewall access. |
void |
setLocalFile(java.lang.String localFile)
The file on the local host. |
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 |
setLocalPort(int localPort)
The TCP port in the local host where the bean binds. |
void |
setPassword(java.lang.String password)
The password associated with User . |
void |
setProtocol(int protocol)
Sets the protocol to use for the transfer. |
void |
setRemoteFile(java.lang.String remoteFile)
The file on the remote host. |
void |
setRemoteHost(java.lang.String remoteHost)
The remote host to which to connect. |
void |
setRemotePort(int remotePort)
The port for the service (REXEC or RSHELL). |
void |
setTimeout(int timeout)
A timeout for the bean. |
void |
setUser(java.lang.String user)
The identification of the remote user for a transfer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int protRexec
public static final int protRshell
Constructor Detail |
---|
public Rcp()
public Rcp(java.lang.String runtimeLicense)
Method Detail |
---|
public java.lang.String getFileMode()
RemoteFile
.
This property contains the file mode for the RemoteFile
. This property is used together with the PutFile
method.
The default mode is "0600".
public void setFileMode(java.lang.String fileMode) throws IPWorksException
RemoteFile
.
This property contains the file mode for the RemoteFile
. This property is used together with the PutFile
method.
The default mode is "0600".
IPWorksException
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 getLocalFile()
This property points to the file on the local host. When GetFile
is called and the file already exists, it is overwritten.
When PutFile
is called this property must point to a valid file,
or an error will be returned.
public void setLocalFile(java.lang.String localFile) throws IPWorksException
This property points to the file on the local host. When GetFile
is called and the file already exists, it is overwritten.
When PutFile
is called this property must point to a valid file,
or an error will be returned.
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 int getLocalPort()
The LocalPort
property 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 it to 0 (default) enables the bean to choose a port
at random. The chosen port will be shown by the LocalPort
property after the connection is established.
LocalPort
cannot be changed once a connection is made.
Any attempt to set the LocalPort
property when a connection
is active will generate an error.
Use this property with caution. If you supply a value,
it must be an available port on the system, or an error will be
returned. Furthermore, the bean always attempts to bind to
a secure (sub 1000) port when the value of LocalPort
is the
default (0). If you supply your own value, make sure the remote
system is configured to allow that particular value.
public void setLocalPort(int localPort) throws IPWorksException
The LocalPort
property 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 it to 0 (default) enables the bean to choose a port
at random. The chosen port will be shown by the LocalPort
property after the connection is established.
LocalPort
cannot be changed once a connection is made.
Any attempt to set the LocalPort
property when a connection
is active will generate an error.
Use this property with caution. If you supply a value,
it must be an available port on the system, or an error will be
returned. Furthermore, the bean always attempts to bind to
a secure (sub 1000) port when the value of LocalPort
is the
default (0). If you supply your own value, make sure the remote
system is configured to allow that particular value.
IPWorksException
public java.lang.String getPassword()
User
.
This property needs to be set to the password that the RemoteHost
has associated with the User
. This property is needed
only if the Protocol
used is REXEC.
public void setPassword(java.lang.String password) throws IPWorksException
User
.
This property needs to be set to the password that the RemoteHost
has associated with the User
. This property is needed
only if the Protocol
used is REXEC.
IPWorksException
public int getProtocol()
This property determines the protocol mechanism used to communicate with the remote host. It has two possible values:
public void setProtocol(int protocol) throws IPWorksException
This property determines the protocol mechanism used to communicate with the remote host. It has two possible values:
IPWorksException
public java.lang.String getRemoteFile()
This property indicates the file on the remote host. When GetFile
is called, this property must be a valid file on
the RemoteHost
.
public void setRemoteFile(java.lang.String remoteFile) throws IPWorksException
This property indicates the file on the remote host. When GetFile
is called, this property must be a valid file on
the RemoteHost
.
IPWorksException
public java.lang.String getRemoteHost()
This property indicates the remote hose to which to connect. Set this property to a valid Internet address of a computer
that is running REXEC or RSHELL services. If the computer is
not running the service that the Protocol
property is set
to, then the connection will fail.
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 indicates the remote hose to which to connect. Set this property to a valid Internet address of a computer
that is running REXEC or RSHELL services. If the computer is
not running the service that the Protocol
property is set
to, then the connection will fail.
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 int getRemotePort()
This property indicates the port for the service (REXEC or RSHELL). The value of this property is set automatically to 512 for REXEC
or 514 for RSHELL every time the Protocol
property is set.
Please refer to the description of the Protocol
property for
more information.
public void setRemotePort(int remotePort) throws IPWorksException
This property indicates the port for the service (REXEC or RSHELL). The value of this property is set automatically to 512 for REXEC
or 514 for RSHELL every time the Protocol
property is set.
Please refer to the description of the Protocol
property for
more information.
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 java.lang.String getUser()
This property contains the identification of the remote user for a transfer. This identification is necessary for use with the protocols REXEC and RSHELL.
public void setUser(java.lang.String user) throws IPWorksException
This property contains the identification of the remote user for a transfer. This identification is necessary for use with the protocols REXEC and RSHELL.
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.
EnableStderr
configuration setting for more information.
Stdout
property.
The default value is -1, which indicates there is no maximum. A value of zero (0) will disable accumulation
of stdout in the Stdout
property, although the Stdout
event will still continue to fire.Stderr
property.
The default value is -1, which indicates there is no maximum. A value of zero (0) will disable accumulation
of stderr in the Stderr
property, although the Stderr
event will still continue to fire.
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 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 getFile() throws IPWorksException
This method gets the specified file. A connection is made with the RemoteHost
using the specified Protocol
, User
, and Password
, and a request is sent to
read the file specified by RemoteFile
.
Example (Get a File)
RCPControl.RemoteHost = "MyServer"
RCPControl.User = "username"
RCPControl.Password = "password"
RCPControl.Protocol = protRexec
RCPControl.RemoteFile = "/remotefile.txt"
RCPControl.LocalFile = "C:\\filename.txt"
RCPControl.GetFile()
IPWorksException
public void interrupt() throws IPWorksException
If there is no method in progress, Interrupt
simply returns, doing nothing.
IPWorksException
public void putFile() throws IPWorksException
This method makes a connection, a request is sent to copy LocalFile
to
the file specified by RemoteFile
.
Example (Put a File)
RCPControl.RemoteHost = "MyServer"
RCPControl.User = "username"
RCPControl.Password = "password"
RCPControl.Protocol = protRexec
RCPControl.RemoteFile = "/remotefile.txt"
RCPControl.LocalFile = "C:\\filename.txt"
RCPControl.PutFile()
IPWorksException
public void addRcpEventListener(RcpEventListener l) throws java.util.TooManyListenersException
java.util.TooManyListenersException
public void removeRcpEventListener(RcpEventListener l)
|
IP*Works! V9 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |