2015-01-17 20:00:57|?次阅读|上传:wustguangh【已有?条评论】发表评论
关键词:C/C++, 网络通信|来源:唯设编程网
//退出FTP服务器
int CFTP::ftp_quit()
{
sprintf_s(m_cmd,"QUIT
");
int err = ftp_sendcmd(m_cmd,m_resp,sizeof(m_resp));
if(err)
return -1;
//得到返回码
int code = get_state_code(m_resp);
//221 Goodbye.
if(code != 221)
return -1;
return 0;
}
退出FTP服务器通过发送命令QUIT实现。
//进入指定的FTP目录
int CFTP::ftp_cd( const char* dir )
{
sprintf_s(m_cmd,"CWD %s
",dir);
int err = ftp_sendcmd(m_cmd,m_resp,sizeof(m_resp));
if(err)
return -1;
//得到返回码
int code = get_state_code(m_resp);
//250 CWD command successful.
/*
550-The system cannot find the file specified.
Win32 error: The system cannot find the file specified.
Error details: File system returned an error.
550 End
*/
if(code != 250)
return -1;
return 0;
}
通过命令CWD可以进入指定的FTP目录。
//返回上级FTP目录
int CFTP::ftp_cdup()
{
sprintf_s(m_cmd,"CDUP
");
int err = ftp_sendcmd(m_cmd,m_resp,sizeof(m_resp));
if(err)
return -1;
//得到返回码
int code = get_state_code(m_resp);
//250 CDUP command successful.
/*
550-The system cannot find the file specified.
Win32 error: The system cannot find the file specified.
Error details: File system returned an error.
550 End
*/
if(code != 250)
return -1;
return 0;
}
返回上级目录通过命令CDUP实现。