GetFtpConnect 异常

coldplay968 2008-03-18 06:01:24

在一个线城函数中调用下面这段

CInternetSession cis;
cis.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 3000);

CString m_strServer, m_strObject;
INTERNET_PORT nPort;
DWORD dwServerType;
CString strURL(_T("ftp://am:am@ftp.66ys.cn:10168/[66影视www.66ys.cn]阿明.rmvb" ) );
AfxParseURL(strURL,dwServerType,m_strServer,m_strObject, nPort);


CFtpConnection * pFtp = NULL;
try
{

// pFtp=cis.GetFtpConnection(_T("ftp.66ys.cn"), _T("am"),_T("am"),m_dwPort);
pFtp=cis.GetFtpConnection(m_strServer,_T("am"),_T("am"),m_dwPort);
}
catch (CInternetException* excep )
{
// 程序运行到这里就异常了
DWORD dwErrorCode = excep->m_dwError;
CString szError;
szError.Format(
_T("Connect Ftp server failed,the error code is:%d"),dwErrorCode);
AfxMessageBox(szError);
excep->Delete();
return;
}
// 为什么会异常啊,是什么原因, ErrorCode 12029

...全文
159 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
vanxining 2008-10-01
  • 打赏
  • 举报
回复
怎么一回事啊?可不可以说一说?
coldplay968 2008-03-20
  • 打赏
  • 举报
回复
谢谢,我已经知道是哪里的问题了
coldplay968 2008-03-19
  • 打赏
  • 举报
回复
有个新问题,SetCurrentDirectory 失败
ftp://ftp.microsoft.com/bussys/winsock/wsguide.doc

CFtpConnection* pConn = NULL;
pConn = session.GetFtpConnection(strServerAddress,strUser,strPassword);
if (pConn)
{
// SetCurrentDirectory 失败,这里的参数是不是_T("/bussys/winsock/")
// 是不是参数错了
pConn->SetCurrentDirectory(strServerPath);

}
CrownLiu 2008-03-19
  • 打赏
  • 举报
回复
#include <afxinet.h>
//-----------------------------------------------------------------------------
int main(void)
{
int iReturnValue = -1;
DWORD dwErrorCode;
DWORD dwIntError;
DWORD dwLength;
char szBuffer[1024];

CInternetSession is("Ftp Test");
CFtpConnection* pConn = NULL;

pConn = is.GetFtpConnection("ftp.microsoft.com");

if (pConn != NULL)
{
iReturnValue = pConn->SetCurrentDirectory("/bussys/winsock");

if (iReturnValue == 0)
{
dwErrorCode = GetLastError();
if (dwErrorCode == ERROR_INTERNET_EXTENDED_ERROR)
{
InternetGetLastResponseInfo (&dwIntError, NULL, &dwLength);
if (dwLength > 0)
{
InternetGetLastResponseInfo (&dwIntError, (LPTSTR) szBuffer, &dwLength);
}
}
}

}

delete pConn;

is.Close();

printf("Resut value is %d\n", iReturnValue);

if (iReturnValue == 0)
{
printf("Error message is %s\n", szBuffer);
}

return 0;
}
CrownLiu 2008-03-18
  • 打赏
  • 举报
回复
Wininet.h

#define ERROR_INTERNET_CANNOT_CONNECT (INTERNET_ERROR_BASE + 29)

我用的VC6.0
CrownLiu 2008-03-18
  • 打赏
  • 举报
回复
12029 无法建立与服务器的连接
coldplay968 2008-03-18
  • 打赏
  • 举报
回复
访问 FTP.MICROSOFT.COM 这个地址就不会报错,
是不是对方的服务器上设置了什么,
ftp://am:am@ftp.66ys.cn:10168/[66影视www.66ys.cn]阿明.rmvb
用讯雷可以下载,用flashget就下载不了

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧