-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtcpthread.h
76 lines (49 loc) · 1.36 KB
/
tcpthread.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef TCPTHREAD_H
#define TCPTHREAD_H
#include <QThread>
#include <QTcpSocket>
#include <QtNetwork>
#include <QTimer>
#include <protocal.h>
#include <parseJson/parsejson.h>
class TcpThread : public QThread
{
Q_OBJECT
public:
//TcpThread();
TcpThread(QObject *parent = 0);
void run();
~TcpThread();
bool linkServer(void);
void breakServer();
void initAllConnect(void);
void sendCheckConn(int useroperate,quint16 operatecmd,
int datasize,QString datadetail);
void reviceIfConnection();
ParseJson *threadparsejson;
QTcpSocket *tcpSocket;
signals:
void error(QTcpSocket::SocketError socketError);
void sendIfConnect(int useroperate,quint16 operatecmd,
int datasize,QString datadetail);
void bytesArrived(qint64,qint32,int);
void singalJson(QByteArray);
public slots:
void receiveFile();
void slotsendInfo(int,quint16,int,QString);
void timedone();
void readyToRead();
private:
int socketDescriptor;
qint64 bytesReceived; //收到的总字节
qint64 byteToRead; //准备读取的字节
qint32 TotalBytes; //总共传输的字节
QHostAddress fileName; //文件名
QFile *localFile;
QByteArray inBlock; //读取缓存
QTimer *timer;
Protocal *threadprotocal;
static int time;
static int time2;
};
#endif // TCPTHREAD_H