L_InetSendRawData

#include "l_bitmap.h"
#include "ltnet.h"

L_LTNET_API L_INT L_InetSendRawData(hComputer, pBuffer, pulBufferLength)

L_COMP hComputer;

/* 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

hComputer

Handle 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 L_InetSendData. L_InetSendRawData does not add any headers. The remote computer must disable auto process by calling L_InetAutoProcess 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 L_InetSendRawData and keep auto process disabled on the remote computer for that connection.

You must initialize the LEADTOOLS Internet DLL using L_InetStartUp 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:

L_InetSendData, L_InetConnect, L_InetClose, L_InetReadData, L_InetSendBitmap, L_InetSendSound, L_InetAutoProcess, L_InetServerInit, L_InetClearQueue, L_InetGetQueueSize, L_InetStartUp, L_InetShutDown

Topics:

Internet Functions

Example

L_INT  EXT_CALLBACK InetCallback(L_COMP hComp,
                                L_INT nMessage, 
                                L_INT nError, 
                                L_CHAR *pBuffer,
                                L_SIZE_T  lSize, 
                                L_VOID *pUserData);
/* note: instead of server_address you need to put the IP address
of the computer running the server. You can also put in
the computer name, if the server is running on a local network */
/* you do not need to use MakeProcInstance for 32 bit applications */
L_INT  InetSendRawDataExample(L_COMP hComp /* handle of the remote computer */)
{
   L_INT nRet;
   nRet = L_InetConnect("server_address", 1000, &hComp, InetCallback, NULL);
   if(nRet != SUCCESS)
   {
      MessageBox(NULL, TEXT("Error attempting to connect"), TEXT("ERROR"), MB_OK);
      return nRet;
   }
   return SUCCESS; 
}
L_INT EXT_CALLBACK InetSendRawDataExample(L_COMP   hComp,
                                          L_INT    nMessage,
                                          L_INT    nError,
                                          L_CHAR * pBuffer,
                                          L_SIZE_T lSize,
                                          L_VOID * pUserData)
{
   UNREFERENCED_PARAMETER(pBuffer);
   UNREFERENCED_PARAMETER(lSize);
   UNREFERENCED_PARAMETER(pUserData);
   L_INT    nRet;
   L_CHAR * pData;
   L_SIZE_T lDataSize;
   switch(nMessage)
   {
      case INET_CONNECT:
         /* check the status and send some data */
         if(nError == SUCCESS)
         {
            pData = "Some Data";
            lDataSize = strlen(pData);
            /* now you can assume you are connected to computer 'hComp' */
            nRet = L_InetSendRawData(hComp, pData, &lDataSize);
            /* remove the next line if you want to keep the connection open Note that 
               not all the data might have been sent at this point. The connection will 
               be closed wither now, or after all the data has been sent */
            L_InetClose(hComp, TRUE);
         }
         else
            MessageBox(NULL, TEXT("You have failed to connect!"), TEXT("Error"), MB_OK);
      break;
   }
   return SUCCESS;
}