OSDN Git Service

Fixed server and client bugs.
[greensite/jasmine.git] / client / tcpclient.h
1 #pragma once
2 #include <QtNetwork>
3 //By default, timeout (i.e. connection timeout,sending timeout, and receiving timeout) is 10000 ms. which is 10 sec.
4 #define TIMEOUT 10000
5 namespace network{
6         class tcpClient:public QTcpSocket{
7                 Q_OBJECT
8         public:
9                 tcpClient(quint64 buffersize,const QString &senderName,QObject *parent=NULL);
10                 tcpClient &operator<<(const QString &),
11                                   &operator<<(QFile &);
12                 quint64 timeout() const;
13                 void timeout(const quint64);
14         protected:
15                 void disconnectFromHostImplementation();
16         signals:
17                 void sentData();
18         private slots:
19                 void data_available();
20         private:
21                 quint64 buffer_size,timeout_time;
22                 bool check_byte_written_and_wait_written(),
23                          check_and_wait_byte_available();
24                 bool want_disconnect;
25                 QString senderName;
26         };
27 }