- 论坛徽章:
- 1
|
本帖最后由 wind_133 于 2016-07-21 12:13 编辑
//send CMD
int ftp_client_class::SEND_CMD(std::string CMD)
{
write(server_socket_ctrl,
CMD.c_str(),
CMD.length()
);
read_res=read(server_socket_ctrl,read_buf,1024);
if (read_res!=0)
{
perror("read");
}
std::cout<<read_buf<<std::endl;
return 0;
}
main.cpp如下:
#include<c_func.h>
#include<string>
int main()
{
ftp_client_class test01;
test01.set_connect_info("test","phoenix","xxxxx");
test01.ftp_connect();
test01.SEND_CMD("CWD /home/phoenix\n");
test01.SEND_CMD("LIST /home/phoenix\n");
return 0;
}
想向ftp服务器发送一个LIST命令列出当前目录下的文件列表,但是却无法打印结果,程序执行是这样的:
test
192.168.1.105
read: Success
220 Welcome message
read: Success
331 Please specify the password.
read: Success
230 Login successful.
read: Success
227 Entering Passive Mode (192,168,1,105,117,95).
read: Success
250 Directory successfully changed.
read: Success
150 Here comes the directory listing.//到这里就结束了,没有打印当前的文件列表。
|
|