L_InetGetQueueSize
#include "l_bitmap.h"
#include "ltnet.h"
L_LTNET_API L_INT L_InetGetQueueSize(hComputer, pulLength)
L_COMP hComputer; |
/* handle of remote computer */ |
L_SIZE_T *pulLength; |
/* address of variable to update */ |
Gets the size of the LEADTOOLS internal send queue.
Parameter |
Description |
hComputer |
Handle of the computer. |
pulLength |
Address of the variable to be updated with the length of the internal send queue. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
If this function returns SUCCESS, pulLength will be updated with the size of the internal send queue. Only actual data will be counted. The LEADTOOLS' headers which pad the data are not counted.
If pulLength is 0, then there is no data in the queue.
If pulLength is between 1 and 0xFFFFFFFE, then it represents the number of bytes in the queue, not counting any LEADTOOLS headers.
If pulLength is QUEUE_NO_DATA (0xFFFFFFFF), then there is no data but the queue is not empty and consists only of LEADTOOLS' headers used for auto process.
Note: |
Even if pulLength is 0, then there is no guarantee that all bytes have been sent and you can do a hard close (i.e. L_InetClose(hComputer, FALSE) ). |
Winsock (which LEADTOOLS uses) has its own internal queue and we have no access to it. Therefore we have no way of knowing how much data has been sent.
You must initialize the LEADTOOLS Internet 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
Functions: |
L_InetClearQueue, L_InetSendData, L_InetSendBitmap, L_InetSendRawData, L_InetSendSound, L_InetStartUp, L_InetShutDown |
Topics: |
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 InetGetQueueSizeExample(L_COMP hComp, /* handle of the remote computer */ L_VOID *pUserData ) { L_INT nRet; nRet = L_InetConnect("server_address", 1000, &hComp, InetCallback, pUserData); if(nRet != SUCCESS) { MessageBox(NULL, TEXT("Error attempting to connect"), TEXT("ERROR"), MB_OK); return nRet; } return SUCCESS; } L_INT EXT_CALLBACK InetCallback(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_INT nRet; static L_CHAR aData[50000] = "Some Data"; L_SIZE_T lDataSize; switch(nMessage) { case INET_CONNECT: /* check the status and send some data */ if(nError == SUCCESS) { /* now you can assume you are connected to computer 'hComp' */ lDataSize = sizeof(aData); nRet = L_InetSendData(hComp, aData, &lDataSize, IDATA_USER1); L_InetGetQueueSize(hComp, &lDataSize); /* abort the current send if less than 25k have been sent */ if(lDataSize > 0 && lDataSize < 25000) L_InetClearQueue(hComp); /* 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; }