- Timestamp:
- Mar 30, 2008, 6:08:45 PM (17 years ago)
- Location:
- trunk/BNS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNS/bnseph.cpp
r758 r759 22 22 //////////////////////////////////////////////////////////////////////////// 23 23 t_bnseph::t_bnseph(QObject* parent) : QThread(parent) { 24 _socket = 0; 24 25 } 25 26 … … 27 28 //////////////////////////////////////////////////////////////////////////// 28 29 t_bnseph::~t_bnseph() { 30 delete _socket; 29 31 } 30 32 … … 32 34 //////////////////////////////////////////////////////////////////////////// 33 35 void t_bnseph::run() { 34 emit(newMessage("============ Start bnseph ============")); 36 37 emit(newMessage("bnseph::run Start")); 38 39 // Connect the Socket 40 // ------------------ 41 QSettings settings; 42 QString host = settings.value("ephHost").toString(); 43 int port = settings.value("ephPort").toInt(); 44 45 _socket = new QTcpSocket(); 46 _socket->connectToHost(host, port); 47 48 const int timeOut = 10*1000; // 10 seconds 49 if (!_socket->waitForConnected(timeOut)) { 50 emit(newMessage("bnseph::run Connect Timeout")); 51 delete _socket; _socket = 0; 52 return; 53 } 54 55 while (true) { 56 if (_socket->canReadLine()) { 57 QByteArray line = _socket->readLine(); 58 emit(newMessage(line)); 59 } 60 else { 61 _socket->waitForReadyRead(10); 62 } 63 } 35 64 } 36 65 -
trunk/BNS/bnseph.h
r758 r759 3 3 4 4 #include <QThread> 5 #include <Q Mutex>5 #include <QtNetwork> 6 6 7 7 class t_bnseph : public QThread { … … 16 16 17 17 private: 18 Q Mutex _mutex;18 QTcpSocket* _socket; 19 19 }; 20 20 #endif
Note:
See TracChangeset
for help on using the changeset viewer.