L_InetCreatePacket
#include "l_bitmap.h"
#include "ltnet.h"
L_INT EXT_FUNCTION L_InetCreatePacket(phPacket, uExtra, pExtra, pszFormat, …)
pHINETPACK phPacket; |
/* pointer to a packet */ |
L_UINT uExtra; |
/* size of the binary data*/ |
/* binary data to be sent */ | |
/* 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
L_COMP hComputer;
#define CMD_FLIP CMD_USER_CUSTOM + 1
#define CMD_ROTATE CMD_USER_CUSTOM + 2
L_VOID FlipCurrentRemoteBitmap()
{
HINETPACK cmdFlip;
/* 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. */
L_InetCreatePacket(&cmdFlip,0,NULL,NULL);
L_InetSendCmd(hComputer,
CMD_FLIP, 1, cmdFlip);
L_InetFreePacket(cmdFlip);
}
/*
This 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*/
L_VOID RotateRemoteBitmap(L_UINT uBitmapID)
{
HINETPACK cmdRotate;
/* Create a packet for a rotate command. Note that it
contains no binary data, one integer parameter and three unsigned integer
parameters */
L_InetCreatePacket(&cmdRotate,0,NULL,"%ud%d%ud%ud",uBitmapID,
45, ROTATE_RESIZE,RGB(255,0,0));
L_InetSendCmd(hComputer,
CMD_ROTATE, 2, cmdRotate);
L_InetFreePacket(cmdRotate);
}