LInet::ReadData

#include "ltwrappr.h"

L_INT LInet::ReadData(plRemoteComp, pBuffer, pulBufferLength)

LInet plRemoteComp;

/* remote computer instance */

L_CHAR L_FAR * pBuffer;

/* pointer to the data buffer */

L_INT32 L_FAR * pulBufferLength;

/* address of length of buffer */

Reads data from a remote computer.

Parameter

Description

plRemoteComp

An instance of the remote computer from which data is being sent.

pBuffer

Address of the buffer to be filled with the read data

pulBufferLength

Address of the variable to be updated with the size of the read data

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

After this function returns, pulBufferLength will be updated with the actual length of read data. This function should only be used if auto process is disabled. You should call this function in response to the LInet::OnDataReady function.

You must initialize the LEADTOOLS Internet DLL using LInet::StartUp before calling this function.

Required DLLs and Libraries

LTNET

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LInet::EnableAutoProcess, LInet::SendData, LInet::SendBitmap, LInet::SendSound, LInet::Connect, LInet::Close, LInet::ReadData, LInet::ServerInit, LInet::OnDataReady, LInet::StartUp, LInet::ShutDown, Class Members

Example

// The user should derive a class from LInet to support the OnConnect and OnDataReady callback functions
// Suppose it was named as LUserInet

LUserInet UserInet;
UserInet.StartUp();

// connect to LEAD.
UserInet.Connect("207.238.49.190", 1000);

// other operations

UserInet.ShutDown();

L_INT LUserInet::OnConnect(LInet L_FAR *plConnection, L_INT nError)
{
   L_INT nRet = SUCCESS;

   if (nError != SUCCESS)
      return nError;

   // set auto process to False to receive OnDataReady
   if ( !plConnection->IsAutoProcessEnabled())
        nRet = plConnection->EnableAutoProcess(FALSE);

   return nRet;

}

L_INT LUserInet::OnDataReady(LInet L_FAR *plConnection, L_INT nError, L_VOID L_FAR *pBuffer, L_UINT32 ulSize)
{
   HGLOBAL          hData = NULL;
   L_CHAR L_FAR *pData;
   L_INT nRet = SUCCESS;

   if (nError != SUCCESS)
     return nError;

   hData = GlobalAlloc(GHND, ulSize + 1);
   pData = (L_CHAR L_FAR *)GlobalLock(hData);
   if ( !pData)
   {
      GlobalUnlock(hData); 
      return FAILURE;
   }

   nRet = ReadData(plConnection, pData, &ulSize);
   pData[ulSize] = 0; // make the data NULL-terminated
   MessageBox(NULL, (L_TCHAR*)pData, TEXT("Data received"), MB_OK);

   GlobalUnlock(hData);
   GlobalFree(hData);

    return nRet;
}