-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTcpConnection.h
50 lines (41 loc) · 1.35 KB
/
TcpConnection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef TCPCONNECTION_H
#define TCPCONNECTION_H
#include <QObject>
#include"QTcpSocket"
#include"QByteArray"
#include"QString"
#include"QUrl"
#include"QFileDialog"
#include"QFile"
#include"QNetworkReply"
#include"QDebug"
#include"QHostAddress"
class TcpConnection : public QObject
{
Q_OBJECT
public:
explicit TcpConnection(QObject *parent = 0);
QTcpSocket *tcpClient;
void download(QUrl url);
void startRequest(QUrl url);
void startUpload(QString fileName);
signals:
private slots:
//void updateClientProgress(qint64); //发送数据,更新进度条
void displayError(QAbstractSocket::SocketError); //显示错误
void reciveData();
private :
QFile *localFile; //要发送的文件
qint64 totalBytes; //数据总大小
qint64 bytesWritten; //已经发送数据大小
qint64 bytesToWrite; //剩余数据大小
qint64 loadSize; //每次发送数据的大小
QByteArray outBlock; //数据缓冲区,即存放每次要发送的数据
qint64 DownloadtotalBytes; //存放总大小信息
qint64 bytesReceived; //已收到数据的大小
qint64 fileNameSize; //文件名的大小信息
QString fileName; //存放文件名
QFile *DownloadlocalFile; //本地文件
QByteArray inBlock; //数据缓冲区
};
#endif // TCPCONNECTION_H