基本信息
源码名称:Ftp客户端连接服务器示例(源码+可执行文件)
源码大小:10.26M
文件格式:.rar
开发语言:C/C++
更新时间:2019-06-28
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
本代码实现了搭建ftp客户机,并实现上传下载显示功能。
本代码实现了搭建ftp客户机,并实现上传下载显示功能。
#include"stdafx.h"
#include"FTPClient.h"
#include<iostream>
using namespace std;
int main(int argc, char* argv[])
{
FTPClient ftp; //定义FTP对象
if (argc != 2)
{
cout << "请输入FTP服务器IP地址:";
string a, b;
ftp.subcommend(a, b);
while (!(const_cast<char*>(a.c_str())))
{
cout << "连接失败!请检查输入是否正确!" << endl;
ftp.subcommend(a, b);
}
if (ftp.FTPConnection(const_cast<char*>(a.c_str()), 21))
{
bool flag;
do
{
ftp.useuser();
flag = ftp.usepass();
} while (!flag);
cout << "提示:help命令可获取帮助!" << endl;
cout << endl;
while (true)
{
cout << "FTP>";
string order, detail;
ftp.subcommend(order, detail);
if (detail.length() != 0)
{
memset(ftp.CmdBuf, 0, MAX_SIZE);
memcpy(ftp.CmdBuf, detail.data(), detail.length());
ftp.ishavedetail = true;
}
if (order == "ls")
ftp.listftp(const_cast<char*>(a.c_str()));
else if (order == "stor")
ftp.storfile(const_cast<char*>(a.c_str()));
else if (order == "retr")
ftp.retrfile(const_cast<char*>(a.c_str()));
else if (order == "cwd")
ftp.changedir();
else if (order == "mkd")
ftp.mkdirectory();
else if (order == "help")
ftp.help();
else if (order == "dele")
ftp.deletefile();
else if (order == "about")
ftp.about();
else if (order == "quit")
{
ftp.quitftp();
break;
}
else if (order == "user")
{
bool flag;
do
{
ftp.useuser();
flag = ftp.usepass();
} while (!flag);
}
else
{
cout << "FTP>无此命令!帮助请输入help!" << endl;
}
ftp.ishavedetail = false;
}
}
}
return 0;
}