Packet Sniffer SDK DLL Edition

HNAdapter :: Properties :: AdpSetSendQueue

 Previous Next

Sets the handle of HNQueue object for packets sending.

Syntax:

HANDLE __stdcall AdpSetSendQueue(HANDLE hAdp, HANDLE hQue);

Parameters:

hAdp

[in] HNAdapter object handle.

hQue

[in] HNQueue object handle.

Return values:

If the function succeeds the return value will be the HNQueue handle, otherwise the returned value will be NULL.

Description:

Use AdpSetSendQueue to set queue for packets sending.

You can arrange traffic sending using packets queue with help of the HNQueue component. To do this you should set SendQueue to not-NULL before network adapter opening: in this case while adapter opening the HNAdapter object will create additional auxiliary thread which will be awaiting for packets with Full status (see HNQueue). Immediately after such packet appears in the queue, it will be sent to the network and returned to the queue with status Free.

SendQueue property can be changed only when HNAdapter component is closed (see AdpIsOpened).

To set packets queue for the network adapter, please do the following:

...
QueSetMaxPacketSize(hQue,1514);
QueSetItemsCount(hQue,50000);
QueAllocItems(hQue);
AdpSetSendQueue(hAdp,hQue);
...
AdpOpenAdapter(hAdp);
...
for (DWORD i = 0; i < 50000; i++)
{
    HANDLE hPkt = QueGetFreeItem(hQue, INFINITE);
    if (hPkt == NULL) break;
	
    LPVOID pPktData = PktGetPacketData(hPkt);
    ...
    memcpy(pPktData, DataBuff, 1514);
    PktSetIncPacketSize(hPkt, 1514);
	
    QueReturnFullItem(hQue, hPkt);
}
...
AdpCloseAdapter(hAdp);
...
QueFreeItems(hQue);
See also:HNAdapter, HNQueue, AdpGetSendQueue