Platform SDK: Logon Authentication

Example Code: ReceiveBytes

//--------------------------------------------------------------------
//     Define ReceiveBytes()

BOOL ReceiveBytes (SOCKET s, PBYTE pBuf, DWORD cbBuf, DWORD *pcbRead) 
{ 
PBYTE pTemp = pBuf; 
int cbRead =1;
int cbRemaining = cbBuf; 
 
while(cbRemaining && cbRead >0 ) 
{ 
     if(cbRead = recv(
          s, 
          (char *)pTemp, 
          cbRemaining, 
          0)) 
     {
          if (SOCKET_ERROR == cbRead) 
          { 
               HandleError("Recv failed.");
          }
          cbRemaining -= cbRead; 
          pTemp += cbRead; 
          *pcbRead = cbBuf - cbRemaining; 
     } // end if
} // end while
 
return TRUE; 
} // end ReceiveBytes