Changeset 1182 in ntrip
- Timestamp:
- Oct 31, 2008, 3:47:10 PM (16 years ago)
- Location:
- trunk/BNC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bnccaster.cpp
r1179 r1182 212 212 void bncCaster::dumpEpochs(long minTime, long maxTime) { 213 213 214 const char begEpoch = 'A'; 215 const char begObs = 'B'; 216 const char endEpoch = 'C'; 214 const char begEpoch[] = "BEGEPOCH"; 215 const char endEpoch[] = "ENDEPOCH"; 216 217 const int begEpochNBytes = sizeof(begEpoch) - 1; 218 const int endEpochNBytes = sizeof(endEpoch) - 1; 217 219 218 220 for (long sec = minTime; sec <= maxTime; sec++) { … … 268 270 // ---------------------- 269 271 if (_sockets) { 270 int numBytes = sizeof(obs->_o);271 272 QMutableListIterator<QTcpSocket*> is(*_sockets); 272 273 while (is.hasNext()) { 273 274 QTcpSocket* sock = is.next(); 275 int myFlag = 0; 274 276 if (sock->state() == QAbstractSocket::ConnectedState) { 275 277 bool ok = true; 276 int fd = sock->socketDescriptor();277 278 if (first) { 278 if (::write(fd, &begEpoch, 1) != 1) { 279 if (myWrite(sock, begEpoch, begEpochNBytes) != begEpochNBytes) { 280 myFlag = 1; 279 281 ok = false; 280 282 } 281 283 } 282 if (::write(fd, &begObs, 1) != 1) { 283 ok = false; 284 } 285 if (::write(fd, &obs->_o, numBytes) != numBytes) { 284 int numBytes = sizeof(obs->_o); 285 if (myWrite(sock, (const char*)(&obs->_o), numBytes) != numBytes) { 286 myFlag = 2; 286 287 ok = false; 287 288 } 288 289 if (!it.hasNext()) { 289 if (::write(fd, &endEpoch, 1) != 1) { 290 if (myWrite(sock, endEpoch, endEpochNBytes) != endEpochNBytes) { 291 myFlag = 3; 290 292 ok = false; 291 293 } … … 433 435 _confTimer->start(ms); 434 436 } 437 438 // 439 //////////////////////////////////////////////////////////////////////////// 440 int bncCaster::myWrite(QTcpSocket* sock, const char* buf, int bufLen) { 441 int bytesWritten = 0; 442 for (;;) { 443 int newBytes = sock->write(buf+bytesWritten, bufLen-bytesWritten); 444 if (newBytes < 0) { 445 std::cout << "myWrite " << newBytes << " " << sock->state() << std::endl; 446 return newBytes; 447 } 448 else { 449 bytesWritten += newBytes; 450 } 451 if (bytesWritten == bufLen) { 452 return bytesWritten; 453 } 454 } 455 } -
trunk/BNC/bnccaster.h
r1179 r1182 58 58 private: 59 59 void dumpEpochs(long minTime, long maxTime); 60 static int myWrite(QTcpSocket* sock, const char* buf, int bufLen); 60 61 61 62 QFile* _outFile;
Note:
See TracChangeset
for help on using the changeset viewer.