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 L_FAR * pBuffer

/* data buffer */

L_UINT32 lSize;

/* size of the data buffer */

L_VOID L_FAR * 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

[0x0000] connected to remote computer.

 

INET_DATA_READY

[0x0001] data ready to be read

 

INET_CLOSE

[0x0002] connection has been terminated

 

INET_CONNECT_REQUEST

[0x0003] remote computer is requesting a connection

 

INET_DATA_SENT

[0x0004] data has been completely sent to remote

 

INET_DATA_SENDING

[0x0005] queued data has been sent

 

INET_DATA_START

[0x0006] about to start receiving data

 

INET_DATA_RECEIVING

[0x0007] receiving data from a remote connection

 

INET_IMAGE_RECEIVED

[0x0008] an image has been received

 

INET_MMEDIA_RECEIVED

[0x0009] a multimedia object has been received

 

INET_SOUND_RECEIVED

[0x000A] sound block has been received

 

INET_USER1_RECEIVED

[0x000B] user data has been received

 

INET_USER2_RECEIVED

[0x000C] user data has been received

 

INET_USER3_RECEIVED

[0x000D] user data has been received

 

INET_USER4_RECEIVED

[0x000E] 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:

L_InetAutoProcess, L_InetReadData, L_InetSendData

Example

For an example, refer to L_InetConnect or L_InetSendSound.