Definition at line 584 of file Channel.h. References CTR_HEADER_SIZE, DATA_BUFFER_SIZE, HandleError(), ILOG_DEBUG, and mBuffer. Referenced by SendRequest(), and Serve(). 00585 { 00586 int rval; 00587 00588 // first recv CTR message to find out the number of bytes to expect 00589 ILOG_DEBUG("receiving..."); 00590 int nrToRecv = 0; 00591 int nrRecv = 0; 00592 char* bufPtr = mBuffer; 00593 int bufSize = DATA_BUFFER_SIZE + CTR_HEADER_SIZE; 00594 do 00595 { 00596 rval = recv(sock, bufPtr, bufSize-nrRecv, 0); 00597 if (rval == SOCKET_ERROR) 00598 { 00599 HandleError("RecvLarge", true); 00600 return -1; 00601 } 00602 if (rval == 0) 00603 { 00604 ILOG_DEBUG("recv got a 0 bytes message"); 00605 return 0; 00606 } 00607 if (nrToRecv == 0) 00608 { // read CTR header for number of bytes to receive 00609 sscanf(bufPtr, "CTR %d", &nrToRecv); 00610 ILOG_DEBUG("recv expects " << nrToRecv << " bytes" 00611 ); 00612 } 00613 ILOG_DEBUG(" recv " << rval << " bytes"); 00614 bufPtr += rval; 00615 nrRecv += rval; 00616 } 00617 while (nrRecv < nrToRecv); 00618 00619 ILOG_DEBUG("received " << nrRecv << " bytes"); 00620 if (nrRecv > nrToRecv) 00621 { 00622 HandleError("received MORE bytes than expected!", true); 00623 return -1; 00624 } 00625 return nrRecv; 00626 }
Here is the call graph for this function:
|