- Timestamp:
- Apr 16, 2008, 1:28:38 PM (17 years ago)
- Location:
- trunk/BNS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNS/bnseph.cpp
r830 r838 35 35 } 36 36 37 // Start37 // Connect the Socket 38 38 //////////////////////////////////////////////////////////////////////////// 39 void t_bnseph::r un() {39 void t_bnseph::reconnect() { 40 40 41 emit(newMessage("bnseph::run Start"));41 delete _socket; 42 42 43 // Connect the Socket44 // ------------------45 43 QSettings settings; 46 44 QString host = "localhost"; … … 50 48 _socket->connectToHost(host, port); 51 49 52 const int timeOut = 3*1000; // 3seconds50 const int timeOut = 10*1000; // 10 seconds 53 51 if (!_socket->waitForConnected(timeOut)) { 54 emit( error("bnseph::run Connect Timeout"));52 emit(newMessage("bnseph::run Connect Timeout")); 55 53 } 56 else { 57 while (true) { 58 if (_socket->state() != QAbstractSocket::ConnectedState) { 59 emit(error("bnseph::not connected")); 60 break; 61 } 54 } 55 56 // Start 57 //////////////////////////////////////////////////////////////////////////// 58 void t_bnseph::run() { 59 60 emit(newMessage("bnseph::run Start")); 61 62 while (true) { 63 if (_socket == 0 || _socket->state() != QAbstractSocket::ConnectedState) { 64 reconnect(); 65 } 66 if (_socket && _socket->state() == QAbstractSocket::ConnectedState) { 62 67 if (_socket->canReadLine()) { 63 68 readEph(); … … 66 71 _socket->waitForReadyRead(10); 67 72 } 73 } 74 else { 75 msleep(10); 68 76 } 69 77 } -
trunk/BNS/bnseph.h
r800 r838 51 51 52 52 private: 53 void reconnect(); 53 54 void readEph(); 54 55 QTcpSocket* _socket;
Note:
See TracChangeset
for help on using the changeset viewer.