Changeset 5647 in ntrip for trunk/BNC/src/bnccaster.cpp


Ignore:
Timestamp:
Feb 23, 2014, 5:53:18 PM (10 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bnccaster.cpp

    r5528 r5647  
    129129  }
    130130#endif
     131
     132  // Miscellaneous output port  // Georg
     133  // -------------------------
     134  _miscMount = settings.value("miscMount").toString();
     135  _miscPort  = settings.value("miscPort").toInt();
     136  if (!_miscMount.isEmpty() && _miscPort != 0) {
     137    _miscServer = new QTcpServer;
     138    if ( !_miscServer->listen(QHostAddress::Any, _miscPort) ) {
     139      emit newMessage("bncCaster: Cannot listen on Miscellaneous Output Port", true);
     140    }
     141    connect(_miscServer, SIGNAL(newConnection()), this, SLOT(slotNewMiscConnection()));
     142    _miscSockets = new QList<QTcpSocket*>;
     143  }
     144  else {
     145    _miscServer  = 0;
     146    _miscSockets = 0;
     147  }
    131148}
    132149
     
    157174  }
    158175#endif
     176  delete _miscServer;
     177  delete _miscSockets;
    159178}
    160179
     
    579598}
    580599
     600//      // Output into the Miscellaneous socket // Georg
     601//      // ------------------------------------
     602//      if (_miscSockets && _miscMount != "ALL") {
     603//        QMutableListIterator<QTcpSocket*> is(*_miscSockets);
     604//        while (is.hasNext()) {
     605//          QTcpSocket* sock = is.next();
     606//          if (sock->state() == QAbstractSocket::ConnectedState) {
     607//            if (myMiscWrite(sock, data, nBytes) != nBytes) {
     608//              delete sock;
     609//              is.remove();
     610//            }       
     611//          }       
     612//          else if (sock->state() != QAbstractSocket::ConnectingState) {
     613//            delete sock;
     614//            is.remove();
     615//          }       
     616//        }       
     617//      }
     618
     619
     620// New Connection // Georg
     621////////////////////////////////////////////////////////////////////////////
     622void bncCaster::slotNewMiscConnection() {
     623  _miscSockets->push_back( _miscServer->nextPendingConnection() );
     624  emit( newMessage(QString("New client connection on Miscellaneous Output Port: # %1")
     625                   .arg(_miscSockets->size()).toAscii(), true) );
     626}
     627
     628// Write buffer // Georg
     629////////////////////////////////////////////////////////////////////////////
     630int bncCaster::myMiscWrite(QTcpSocket* sock, const char* buf, int bufLen) {
     631  sock->write(buf, bufLen);
     632  for (int ii = 1; ii <= 10; ii++) {
     633    if (sock->waitForBytesWritten(10)) {  // wait 10 ms
     634      return bufLen;
     635    }
     636  }
     637  return -1;
     638}
     639
Note: See TracChangeset for help on using the changeset viewer.