LInet::SendRawData

#include "ltwrappr.h"

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

LInet *plRemoteComp;

/* handle of remote computer */

L_CHAR * pBuffer;

/* pointer to the data buffer to send */

L_SIZE_T * pulBufferLength;

/* address of length of buffer */

Sends data to a remote computer.

Parameter

Description

plRemoteComp

Instance of remote computer to which data will be sent

pBuffer

Pointer to the buffer that contains the data to send

pulBufferLength

Address of a variable that contains the length of buffer, and which will be updated with the amount of data actually sent.

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 amount of data that was actually sent. If pulBufferLength is less than the original value, then the rest of the data is queued, and will be sent at a later time. You do not need to re-send the data.

Note: LEADTOOLS adds its own headers to the data being sent with LInet::SendData. LInet::SendRawData does not add any headers. The remote computer must disable auto process by calling LInet::EnableAutoProcess in order for the raw data to be received properly.

One possible use of this function, is to send raw data to a remote computer to detect if the remote is capable of handling LEADTOOLS headers. If the remote computer cannot handle LEADTOOLS' headers, then you can send all your data with LInet::SendRawData and keep auto process disabled on the remote computer for that connection.

You must initialize the LEADTOOLS Peer-to-Peer 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::SendData, LInet::Connect, LInet::Close, LInet::ReadData, LInet::SendBitmap, LInet::SendSound, LInet::EnableAutoProcess, LInet::ServerInit, LInet::ClearQueue, LInet::GetQueueSize, LInet::StartUp, LInet::ShutDown, Class Members

Topics:

Sending and Receiving Data

Example

// a user defined class derived from LInet should be used to support the OnConnect callback function
// suppose it was named as LUserInetSRD
class LUserInetSRD : public LInet
{
protected:
   virtual  L_INT OnConnect(LInet *plConnection, L_INT nError);
};
L_INT LInet__SendRawDataExample()
{
   L_INT          nRet;
   LUserInetSRD   UserInet;
   nRet = UserInet.StartUp();
   if(nRet != SUCCESS)
      return nRet;
   // connect to LEAD.
   nRet = UserInet.Connect("207.238.49.190", 1000);
   if(nRet != SUCCESS)
      return nRet;
   // other operations
   nRet = UserInet.ShutDown();
   if(nRet != SUCCESS)
      return nRet;
   return SUCCESS;
}
L_INT LUserInetSRD::OnConnect(LInet *plConnection, L_INT nError)
{
   L_CHAR*     pData;
   L_SIZE_T    ulDataSize;
   L_INT       nRet = SUCCESS;
   if (nError != SUCCESS)
      return nError;
   pData = "Some Data";
   ulDataSize = strlen(pData);
   // now you can assume you are connected to remote computer
   nRet = SendRawData(plConnection, pData, &ulDataSize);
   // other operations
   // we can close the connection without data loss with a graceful connection. 
   //The closing occurs immediately 
   // and all the data will not be sent.
   Close(plConnection);
   return nRet;
}