Changeset 637 in ntrip


Ignore:
Timestamp:
Dec 17, 2007, 5:13:44 PM (16 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bnccaster.cpp

    r636 r637  
    3939 * -----------------------------------------------------------------------*/
    4040
     41#include <iostream>
    4142#include <math.h>
    4243#include <unistd.h>
     
    266267        if (_sockets) {
    267268          int numBytes = sizeof(obs->_o);
    268           QListIterator<QTcpSocket*> is(*_sockets);
     269          QMutableListIterator<QTcpSocket*> is(*_sockets);
    269270          while (is.hasNext()) {
    270271            QTcpSocket* sock = is.next();
    271272            if (sock->state() == QAbstractSocket::ConnectedState) {
     273              bool ok = true;
    272274              int fd = sock->socketDescriptor();
    273275              if (first) {
    274                 ::write(fd, &begEpoch, 1);
    275               }
    276               ::write(fd, &begObs, 1);
    277               ::write(fd, &obs->_o, numBytes);
     276                if (::write(fd, &begEpoch, 1) != 1) {
     277                  ok = false;
     278                }
     279              }
     280              if (::write(fd, &begObs, 1) != 1) {
     281                ok = false;
     282              }
     283              if (::write(fd, &obs->_o, numBytes) != numBytes) {
     284                ok = false;
     285              }
    278286              if (!it.hasNext()) {
    279                 ::write(fd, &endEpoch, 1);
    280               }
     287                if (::write(fd, &endEpoch, 1) != 1) {
     288                  ok = false;
     289                }
     290              }
     291              if (!ok) {
     292                delete sock;
     293                is.remove();
     294              }
     295            }
     296            else if (sock->state() != QAbstractSocket::ConnectingState) {
     297              delete sock;
     298              is.remove();
    281299            }
    282300          }
Note: See TracChangeset for help on using the changeset viewer.