/* Receives data from the TCP/IP server in a blocking manner.  */
bool NetAccessReceive(uint8_t *data, uint32_t *length, uint32_t timeout)
/* Receives data from the TCP/IP server in a blocking manner.  */
bool NetAccessReceive(uint8_t *data, uint32_t *length, uint32_t timeout)
{
  bool result = false;
  int tv;
  int receivedLen;
  assert(data != NULL);
  assert(length != NULL);
  assert(timeout > 0);
  if ( (data != NULL) && (length != NULL) && (timeout > 0) &&
       (winsockInitialized) )
  {
    if (netAccessSocket != INVALID_SOCKET)
    {
      tv = (int)timeout;
      if (setsockopt(netAccessSocket, SOL_SOCKET, SO_RCVTIMEO, (char*)&tv, sizeof(int)) != SOCKET_ERROR)
      {
        receivedLen = recv(netAccessSocket, (char *)data, (int)*length, 0);
        if ((receivedLen != SOCKET_ERROR) && (receivedLen > 0))
        {
          *length = (uint32_t)receivedLen;
          result = true;
        }
      }
    }
  }
  return result;
}