我在奇尔卡特例外奇尔卡特连接异常在C#
calling ConnectSocket2
IPV6 enabled connect with NO heartbeat.
Cannot connect, hostname is zero length
ConnectFailReason: 1
Failed to connect to FTP server.
Failed. --ConnectOnly_Ftp2
--ChilkatLog
我试图使用奇尔卡特的FTP2类(使用C#)来连接到FTP服务器获取以下信息,使用Connect方法。
以下是我的类我使用与FTP2
public class FTPClient
{
private Ftp2 m_FtpInfo;
const int FTP_DEFAULT_PORT = 21;
public FTPClient()
{
m_FtpInfo = null;
}
public FTPClient(string userName, string password, string hostName, int port)
{
m_FtpInfo = new Ftp2();
m_FtpInfo.Account = userName;
m_FtpInfo.ClientIpAddress = hostName;
m_FtpInfo.Password = password;
//m_FtpInfo.Port = port;
}
public Ftp2 FTPInfo
{
get
{
if (m_FtpInfo == null)
m_FtpInfo = new Ftp2();
return m_FtpInfo;
}
set { m_FtpInfo = value; }
}
public void Connect()
{
lock (this)
{
if (m_FtpInfo == null)
{
m_FtpInfo = new Ftp2();
}
AppConfiguration appConfiguration = AppConfiguration.Instance;
/*
* Steps to connect to FTP site using Chilkat
* 1. Unlock the component by passing the code provided by Chilkat
* 2. Connect to the Site by specifying the hostname and port
*/
// Unlock the component.
if (!m_FtpInfo.UnlockComponent("AnythingWorksFor30DayTrial"))
{
throw new FTPConnectionExceptions(CommunicationError.UnlockFailed, m_FtpInfo.LastErrorText);
}
// Connect to the FTP server. (use a domain name or IP address)
if (!m_FtpInfo.Connect())
{
throw new FTPConnectionExceptions(CommunicationError.ConnectionFailed, m_FtpInfo.LastErrorText);
}
}
}
public void DisposeConnection()
{
lock (this)
{
if (m_FtpInfo == null) return;
if (m_FtpInfo.IsConnected)
m_FtpInfo.Disconnect();
m_FtpInfo = null;
}
}
连接谁能告诉我在哪里去了?
错误'无法连接,主机名是零length'可能意味着你忘了设定目标服务器。你能提供一些代码(创建一个实例,设置属性,调用连接等)? – Sascha
我编辑了我的帖子,给出与FTP连接的类详细信息 – Sagar