2016-01-05 19:46:22|?次阅读|上传:wustguangh【已有?条评论】发表评论
关键词:C/C++, 网络通信|来源:唯设编程网
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; }
退出命令用QUIT表示,发送成功,服务器的返回码是221。
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命令可以进入指定的服务器目录,执行成功后,服务器的返回码是250.
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命令表示返回上级目录,执行成功的返回码是250.