Qt:基于TCP的多线程文件传输工具

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_37413035/article/details/78773923

FTP (File transfer protocol)是一个古老实用的文件传输协议,方便在客户端和服务器之间进行文件的传输,我们可以在Linux操作系统上使用vsftpd这个软件来搭建 FTP 服务器并创建专有的 FTP 登录账户保障服务器安全,但是它对于非专业用户来说,使用命令行来操作是不太方便的。所以我们可以试着用Qt去实现一个有图形用户界面且功能相似的程序~
这是一个基于C/S模型的多线程文件传输工具,支持客户端对服务器主机的磁盘文件浏览、文件下载、文件上传支持多线程,服务器支持多用户连接。
——by miaoxingxing

#Client端工程目录
FileTransferClient
|— FileTransferClient.pro
|— 头文件
| |— filedownloadwidget.h
| |— fileinformationwidget.h
| |— mainwindow.h
| |— tcplicent.h
|— 源文件
| |— filedownloadwidget.cpp
| |— fileinformationwidget.cpp
| |— main.cpp
| |— mainwindow.cpp
| |— tcplicent.cpp

#Server端工程目录
FileTransferServer
|— FileTransferServer.pro
|— 头文件
| |— filedownloadtablemodel.h
| |— filepathmanager.h
| |— filesendthread.h
| |— mainwindow.h
| |— progressbardelegate.h
| |— serverstatuswidget.h
| |— tcpserver.h
| |— tcpsocket.h
| |— transferstatuswidget.h
|— 源文件
| |— filedownloadtablemodel.cpp
| |— filepathmanager.cpp
| |— filesendthread.cpp
| |— main.cpp
| |— mainwindow.cpp
| |— progressbardelegate.cpp
| |— serverstatuswidget.cpp
| |— tcpserver.cpp
| |— tcpsocket.cpp
| |— transferstatuswidget.cpp

#运行效果
首先启动服务器端程序,点击“开启服务器”,服务器就会在我们设置的端口进行监听。
接着启动客户端程序,在数据传输之前,我们需建立一个TCP连接到远程主机和端口上。填写目标主机ip地址和端口并设置文件保存路径,点击“连接服务器”后我们就可以浏览到服务器主机的磁盘文件并进行文件的上传及下载了~
这里写图片描述
同时服务器端也会同步显示文件传输的进度~
这里写图片描述
这里写图片描述
这里写图片描述

猜你喜欢

转载自blog.csdn.net/weixin_37413035/article/details/78773923