Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
INETCALLBACK Function
#include "l_bitmap.h"
#include "ltnet.h"
L_INT pEXT_CALLBACK YourFunction (hComputer, nMessage, nError, pBuffer, lSize, pUserData)
L_COMP hComputer; |
/* handle to a connected computer */ |
L_INT nMessage; |
/* reason for the callback */ |
L_INT nError; |
/* error code */ |
L_VOID * pBuffer |
/* data buffer */ |
L_UINT32 lSize; |
/* size of the data buffer */ |
L_VOID * pUserData; |
/* pointer to additional parameters */ |
Handles the messages received by a connected computer.
Parameter |
Description |
|
hComputer |
Handle to the computer connection that is receiving the message. |
|
nMessage |
Value indicating reason for the callback. Can be one of the following values: |
|
|
Value |
Meaning |
|
INET_CONNECT |
Connected to remote computer. |
|
INET_DATA_READY |
Data ready to be read. |
|
INET_CLOSE |
Connection has been terminated. |
|
INET_COMMAND_RECEIVED |
A command has been received. |
|
INET_CONNECT_REQUEST |
Remote computer is requesting a connection. |
|
INET_DATA_SENT |
Data has been completely sent to remote. |
|
INET_DATA_SENDING |
Queued data has been sent. |
|
INET_DATA_START |
About to start receiving data. |
|
INET_DATA_RECEIVING |
Receiving data from a remote connection. |
|
INET_DETACH |
Handle has been detached from windows socket. |
|
INET_IMAGE_RECEIVED |
An image has been received. |
|
INET_MMEDIA_RECEIVED |
A multimedia object has been received. |
|
INET_RESPONSE_RECEIVED |
A response has been received. |
|
INET_SOUND_RECEIVED |
Sound block has been received. |
|
INET_USER1_RECEIVED |
User data has been received. |
|
INET_USER2_RECEIVED |
User data has been received. |
|
INET_USER3_RECEIVED |
User data has been received. |
|
INET_USER4_RECEIVED |
User data has been received. |
nError |
If no error has occurred, nError will be SUCCESS. If nError is < SUCCESS, an error has occurred. |
|
pBuffer |
Pointer to a data buffer. The buffer can hold different data, depending on nMessage: |
|
|
Message |
Type of data in pBuffer |
|
INET_IMAGE_RECEIVED |
pBuffer points to a BITMAPHANDLE structure containing the bitmap. |
|
INET_MMEDIA_RECEIVED |
pBuffer points to a MEDIAHANDLE structure containing a multimedia object. |
|
INET_USERx_RECEIVED |
pBuffer points to data of a user-defined format. |
|
INET_SOUND_RECEIVED |
pBuffer points to a WAVEFORMATDATA structure, followed by a WAVEDATA structure. |
|
other |
Not used |
lSize |
The size of the data pointed to by pBuffer. The value depends on nMessage: |
|
|
Message |
Size of data in pBuffer |
|
INET_DATA_READY |
The size of the available data pointed to by pBuffer. |
|
INET_USERx_RECEIVED |
The size of the user-defined data pointed to by pBuffer. |
|
INET_SOUND_RECEIVED |
The size of the data pointed to by pBuffer. |
pUserData |
A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass in the pUserData parameter of the calling function.) |
|
|
Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
If nMessage is INET_IMAGE_RECEIVED, the bitmap pointed to by pBuffer will be freed upon returning from the callback. If you want to keep the bitmap, you can make a copy of the bitmap before returning.
If nMessage is INET_MMEDIA_RECEIVED, the multimedia object pointed to by pBuffer was opened in L_OPEN_READ mode.
If nError is < SUCCESS, pBuffer should be ignored.
The INET_DATA_READY message is sent before the INET_IMAGE_RECEIVED, INET_MMEDIA_RECEIVED or INET_USERx_RECEIVED messages so that you can determine the total amount of data that will be received.
If auto process was not enabled for hComputer, pBuffer will be NULL, and you should read the data by calling L_InetReadData.
Immediately after successfully connecting to a LEADTOOLS server started with L_InetServerInit, the INETCALLBACK function will be called. If auto process is enabled, the first message will be INET_USER1_RECEIVED and pBuffer will contain a NULL terminated string containing "LEAD Technologies Server X.X" where X.X is the server version number. If auto process is not enabled, the first message will be INET_DATA_READY, and the version string can be read using L_InetReadData.
If nMessage is INET_SOUND_RECEIVED, then pBuffer points to a WAVEFORMATDATA structure followed by a WAVEDATA structure.
Note: |
The WAVEFORMATDATA structure is a variable length structure. For more information, refer to the example for L_InetSendSound. |
The buffer pointed to by pBuffer will be freed upon returning from the callback.
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: |
Example
For an example, refer to L_InetConnect or L_InetSendSound.