Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
L_InetSendData
#include "l_bitmap.h"
#include "ltnet.h"
L_LTNET_API L_INT L_InetSendData(hComputer, pBuffer, pulBufferLength, uDataType)
L_COMP hComputer; |
/* handle of remote computer */ |
L_CHAR * pBuffer; |
/* pointer to the data buffer to send */ |
L_SIZE_T * pulBufferLength; |
/* address of a variable to be updated with the length of the buffer */ |
IDATATYPE uDataType; |
/* data type */ |
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. |
|
uDataType |
Value indicating the type of data being sent. This value determines the type of headers added to the data. Possible values are: |
|
|
Value |
Meaning |
|
IDATA_IMAGE |
image data |
|
IDATA_MMEDIA |
multimedia object |
|
IDATA_USER1 |
user data |
|
IDATA_USER2 |
user data |
|
IDATA_USER3 |
user data |
|
IDATA_USER4 |
user data |
|
The receiving computer will receive the appropriate notification in the INETCALLBACK function as follows: |
|
|
On Send: |
On Receive: |
|
IDATA_IMAGE |
INET_IMAGE_RECEIVED |
|
IDATA_MMEDIA |
INET_MMEDIA_RECEIVED |
|
IDATA_USER1 |
INET_USER1_RECEIVED |
|
IDATA_USER2 |
INET_USER2_RECEIVED |
|
IDATA_USER3 |
INET_USER3_RECEIVED |
|
IDATA_USER4 |
INET_USER4_RECEIVED |
|
Note: If an error occurs during sending or receiving and the headers become corrupted, then the receiving computer will receive the INET_USER1_RECEIVED notification. This means that to differentiate your own user-defined data from bad frames, you can use IDATA_USER2, IDATA_USER3 or IDATA_USER4. |
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: |
With this function, LEADTOOLS adds its own headers to the data being sent. These headers need to be stripped by the remote computer, in order for the actual data to be processed. The remote computer can set auto process by calling L_InetAutoProcess in order for the headers to be stripped. |
You must initialize the LEADTOOLS Peer-to-Peer 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
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 InetSendDataExample(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 InetSendDataExample(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_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'*/ L_InetSendData(hComp, pData, &lDataSize, IDATA_USER1); /* we can close the connection without data loss with a graceful connection. The closing is delayed until after all the data has been sent. remove the next line if you want to keep the connection open */ L_InetClose(hComp, TRUE); } else MessageBox(NULL, TEXT("You have failed to connect!"), TEXT("Error"), MB_OK); break; } return SUCCESS; }