[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.dsdp.tm] RSE:How to set timeout to stop the connecting state?

I creat a FTP connection with the specified port such as 8092 which has been used by other applications,and connect the FTP connection,but can not open a Socket connected to a remote host at the specified port(8092) by indirectly call {@link org.apache.commons.net.SocketClient$connect(String hostname, int port)},and keep on connecting state for ever.

Here is my configuration:
- Windows XP PC running Eclipse 3.3.0 with plugin RSE (RSE-SDK-3.0.1.zip)

Here are my code:
/*creat a FTP connection with the specified port such as 8092*/
public IHost creatFTPConnection(String siteName, String ip, int port ){
IHost ftpSite = null;
IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(RSE_SYSTEM_TYPE_ID);
ISubSystemConfigurator[] configurators = getSubSystemConfigurators();
String[] defaultProfileNames = sr.getSystemProfileManager().getActiveSystemProfileNames();
String aliasName = decorateAliasName(siteName);

if(defaultProfileNames.length > 0){
try {
ftpSite = sr.createHost(defaultProfileNames[0], systemType, aliasName, ip,
"", "", 0,configurators);
} catch (Exception e) {
e.printStackTrace();
}
if(ftpSite != null){
ISubSystem[] subsystems = ftpSite.getSubSystems();
for (int i = 0; i < subsystems.length; i++){
ISubSystem subsystem = subsystems[i];
subsystem.getConnectorService().setPort(port);//port=8092
}
}
}
return ftpSite;
}


/*to connect the FTP connection with the specified port such as 8092*/
public class ConnectAllJob extends Job
{
private IHost fFtpSite, fTabDate;
private Viewer fViewer; public ConnectAllJob(IHost site,IHost data, Viewer v )
{
super(SystemResources.ACTION_CONNECT_ALL_LABEL);
fFtpSite = site;
fTabDate = data;
fViewer = v;
}

public IStatus run(IProgressMonitor monitor)
{
List failedSystems = new ArrayList();
try {
//forced instantiation of all subsystems
ISubSystem[] subsystems = fTabDate.getSubSystems();
for (int i = 0; i < subsystems.length; i++)
{
ISubSystem subsystem = subsystems[i];
IConnectorService system = subsystem.getConnectorService();
if (!subsystem.isConnected()
&& subsystem.getSubSystemConfiguration().supportsSubSystemConnect()
&& !failedSystems.contains(system))
{
try
{
subsystem.connect(monitor, false);
}
catch (SystemMessageException e) {
//TODO should we collect all messages and just show one dialog with a MultiStatus?
failedSystems.add(system);
SystemMessageDialog.displayMessage(e);
}
catch (Exception e) {
failedSystems.add(system);
if ((e instanceof InterruptedException) || (e instanceof OperationCanceledException)) {
// if the user was prompted for password and cancelled
// or if the connect was interrupted for some other reason
// we don't attempt to connect the other subsystems
break;
}
SystemBasePlugin.logError(
e.getLocalizedMessage()!=null ? e.getLocalizedMessage() : e.getClass().getName(),
e);

SystemMessageDialog.displayErrorMessage(getShell(), e.getMessage());
}
}
}
} catch (Exception exc) {
} // msg already shown
if (failedSystems.size() > 0)
{
return Status.CANCEL_STATUS;
}
}
}
How to set timeout to stop the connecting state or what is the best way to handle this problem? Somebody can help me?
Best Regards,
hemeihua