FACT++  1.0
bool READ_STRUCT::read ( )

Definition at line 427 of file EventBuilder.cc.

References factPrintf(), MessageImp::kError, MessageImp::kInfo, and time.

Referenced by mainloop().

428 {
429  if (!connected)
430  return false;
431 
432  if (bufLen==0)
433  return true;
434 
435  const int32_t jrd = recv(socket, bufPos, bufLen, MSG_DONTWAIT);
436  // recv failed
437  if (jrd<0)
438  {
439  // There was just nothing waiting
440  if (errno==EWOULDBLOCK || errno==EAGAIN)
441  return false;
442 
443  factPrintf(MessageImp::kError, "Reading from socket %d failed: %m (recv,rc=%d)", sockId, errno);
444  return false;
445  }
446 
447  // connection was closed ...
448  if (jrd==0)
449  {
450  factPrintf(MessageImp::kInfo, "Socket %d closed by FAD", sockId);
451 
452  destroy();//DestroySocket(rd[i]); //generate address and socket
453  return false;
454  }
455 
456  totBytes += jrd;
457 
458  // are we skipping this board ...
459  if (bufTyp==kStream)
460  return false;
461 
462  if (bufPos==B)
463  gettimeofday(&time, NULL);
464 
465  bufPos += jrd; //==> prepare for continuation
466  bufLen -= jrd;
467 
468  // not yet all read
469  return bufLen==0;
470 }
timeval time
void factPrintf(int severity, const char *fmt,...)
uint8_t * bufPos
uint64_t totBytes
uint32_t bufLen
An info telling something which can be interesting to know.
Definition: MessageImp.h:17
void destroy()
uint8_t B[MAX_LEN]
Error, something unexpected happened, but can still be handled by the program.
Definition: MessageImp.h:19
buftyp_t bufTyp

+ Here is the call graph for this function:

+ Here is the caller graph for this function: