Purpose: Read from a socket into a buffer.

Return TypeFunction nameArguments
hzEcodehzTcpClient::Recv(void*,uint32_t&,uint32_t,)

Declared in file: hzTcpClient.h
Defined in file : hzTcpClient.cpp

Function Logic:

0:START 1:cpOut cpOut nRecv 2:unknown 3:Return E_NOSOCKET 4:unknown 5:Return E_OK 6:unknown 7:nBytes 8:nBytes 9:unknown 10:unknown 11:Return E_OK 12:unknown 13:Return E_TIMEOUT 14:Return E_RECVFAIL 15:nRecv 16:Return E_OK

Function body:

hzEcode hzTcpClient::Recv (void* vpOut)uint32_t& nRecv, uint32_t nMax, 
{
   //  Purpose: Read from a socket into a buffer.
   //  
   //  Arguments: 1) vpOut The buffer to populate
   //     2) nRecv A reference to number of bytes received
   //     3) nMax The maximum number of bytes to receive
   //  
   //  Returns: E_NOSOCKET If the connection has been closed
   //     E_RECVFAIL If the socket read operation fails
   //     E_OK  If operation successfull
   _hzfunc("hzTcpClient::Recv(1)") ;
   char*   cpOut ;     //  Buffer recast to char*
   int32_t nBytes ;    //  Bytes recieved in socket read
   cpOut = (char*) vpOut ;
   cpOut[0]= 0;
   nRecv = 0;
   if (!m_nSock)
       return E_NOSOCKET ;
   if (nMax == 0)
       return E_OK ;
   if (m_pSSL)
       nBytes = SSL_read(m_pSSL, cpOut, nMax) ;
   else
       nBytes = recv(m_nSock, cpOut, nMax, 0);
   if (nBytes < 0)
   {
       if (errno == EAGAIN)    return E_OK ;
       if (errno == ETIMEDOUT) return E_TIMEOUT ;
       //  Close() ;
       return E_RECVFAIL ;
   }
   nRecv = nBytes ;
   return E_OK ;
}