Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
L_InetCreatePacket
#include "l_bitmap.h"
#include "ltnet.h"
L_LTNET_API L_INT L_InetCreatePacket(phPacket, uExtra, pExtra, pszFormat, )
pHINETPACK phPacket; |
/* pointer to a packet */ |
L_UINT uExtra; |
/* size of the binary data */ |
L_VOID * pExtra; |
/* binary data to be sent */ |
L_CHAR * pszFormat; |
/* format describing the parameters */ |
|
/* variable list of parameters */ |
Creates a packet.
Parameter |
Description |
|
phPacket |
Pointer to the variable to be updated with the newly created packet. |
|
uExtra |
Size of the binary data. Used only if pExtra is not NULL. |
|
pExtra |
Binary (extra) data to be sent. Use NULL if there is no binary data to send. |
|
pszFormat |
Format of the command parameters. Possible values are: |
|
|
Value |
Meaning |
|
%d |
decimal integer |
|
%l |
long signed integer |
|
%c |
character |
|
%s |
string |
|
%ud |
unsigned long integer |
|
%us |
unsigned short integer |
|
%ss |
signed short integer |
|
%bs |
unsigned string |
|
Variable list of parameters for this command. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function allows the user to create a packet containing the parameters to send to a remote computer. Note that this packet can be used to send both commands and responses. The packet contains a binary chunk (described with uExtra and pExtra) and a variable number of arguments (described by pszFormat). If there are no parameters to send, pszFormat can be either NULL or an empty string ("").
Call L_InetFreePacket when the packet is no longer needed, to free the memory allocated for the packet.
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: |
|
Topics: |
|
|
Example
In the second example, the function will rotate a bitmap, but it will pass the bitmap ID as an argument. The bitmap ID will have to be retrieved from the remote computer. One way to get the bitmap id is to process the response from a CMD_LOAD command.
#define CMD_FLIP (CMD_USER_CUSTOM + 1) #define CMD_ROTATE (CMD_USER_CUSTOM + 2) // Example 1 L_INT InetCreatePacketFirstExample(L_COMP hComputer) { L_INT nRet; HINETPACK cmdFlip = NULL; /* Create a packet for a flip command. The remote program would probably interpret it as 'Flip the current bitmap'. Note that you don't really have to create a packet for commands with no arguments, since you can pass NULL for the packet. We are just showing that you can use NULL or "" as the format string.*/ nRet = L_InetCreatePacket(&cmdFlip,0,NULL,NULL); if(nRet != SUCCESS) return nRet; nRet = L_InetSendCmd(hComputer, (CMDTYPE) CMD_FLIP, 1, cmdFlip); if(nRet != SUCCESS) return nRet; L_InetFreePacket(cmdFlip); return SUCCESS; } // Example 2 L_INT InetCreatePacketSecondExample(L_UINT uBitmapID,L_COMP hComputer) { L_INT nRet; HINETPACK cmdRotate = NULL; /* Create a packet for a rotate command. Note that it contains no binary data, one integer parameter and three unsigned integer parameters */ nRet = L_InetCreatePacket(&cmdRotate,0,NULL,"%ud%d%ud%ud",uBitmapID, 45, ROTATE_RESIZE,RGB(255,0,0)); if(nRet != SUCCESS) return nRet; nRet = L_InetSendCmd(hComputer, (CMDTYPE) CMD_ROTATE, 2, cmdRotate); if(nRet != SUCCESS) return nRet; L_InetFreePacket(cmdRotate); return SUCCESS; }