Packet Sniffer SDK DLL Edition

HNAdapter :: Properties :: AdpSetThreadCount

 Previous Next

Sets the number of threads created for work with the network adapter.

Syntax:

DWORD __stdcall AdpSetThreadCount(HANDLE hAdp, DWORD ThreadCount);

Parameters:

hAdp

[in] HNAdapter object handle.

ThreadCount

[in] The number of threads created for work with the network adapter (from 1 to AdpGetMaxThreadCount).

Return values:

HNERR_OKNo errors.
HNERR_ADAPTER_ALREADY_OPENEDThreadCount must be set before the network adapter opening.
HNERR_ADAPTER_THREAD_COUNTThe number of threads may be only from 1 to AdpGetMaxThreadCount.
HNERR_INVALID_HANDLEhAdp parameter is not the HNAdapter object handle.

Description:

Use AdpSetThreadCount before opening the network adapter (see AdpOpenAdapter).

After the network adapter has been opened, all the operations with Packet Sniffer SDK internal driver (which provides the direct access to the network adapter) are anyway processed by the internal thread(s).

To make the work of Packet Sniffer SDK more effective, very flexible mechanism of the HNAdapter object fine-tuning was created: you may set the number of the threads for working with the network adapter. ThreadCount property, depending on the task you are solving, allows to set the optimal number of such threads.

To make the traffic capturing better, you should take in account the most important hardware configuration characteristics of your system: CPU(s) speed, RAM size, HDD performance, and the network adapter features.

The default value of the ThreadCount property is 1.

1. Please note, that if ThreadCount is greater than 1, then OnPacketReceive event handler also may be called by more than one thread simultaneously.

2. For Windows 95/98/ME this property always is set to 2, because under these operation systems PSSDK always uses 2 threads to increase performance of packets processing and asynchronous operations. The reason is the internal architecture of these operation systems, that doesn't allow to use several CPUs on multi-CPU systems.

3. If the ReceiveQueue property has been set before the network adapter opening, then while executing the code in such operating systems as NT/2000/XP/2003/Vista the ThreadCount will be greater than 1. This is due to the internal implementation of the HNAdapter component in the operating systems mentioned above.
See also:HNAdapter, MaxThreadCount, OnPacketReceive, AdpGetThreadCount, AdpGetReceiveQueue, AdpSetReceiveQueue