kaveInitializeService

The function allows the SDK to connect to the kavehost service in Unix-like operating systems. This service is started separately. For more information, see section "Organizing service mode in Linux".

This function is only supported on Linux platforms. Use the kaveInitializeEx function to start KAV SDK as a service on Windows platforms.

The application must call the kaveUninitialize function to disconnect from the service. The service itself must be stopped by administrators.

Scanner host types and options

The KAV scanner can be run as a separate process or from inside the application. The dwScannerHostType parameter defines the scanner host type; it is specified during SDK initialization. For detailed information about KAV SDK initializing flags, which can be specified in the dwScannerHostType parameter, refer to section "Initialization flags".

Syntax

HRESULT kaveInitializeService (

const char *pComConnString,

const char *pScanConnString,

const char *pEventConnString,

unsigned long dwOutprocScannersCount,

unsigned long dwScanningThreadsCount,

unsigned long dwQueueLength,

PFNCALLBACK pfnUserCallback,

long dwNetworkTimeout);

Parameters

The kaveInitializeService function has the following parameters.

kaveInitializeService function parameters

Name

Type

Description

pComConnString

in

A pointer to the first socket as specified in the kavehost.xml file.

If you are using local communications via UNIX domain sockets, this parameter must point to the kavcom socket.

For more information, see section "Kavehost service configuration file".

pScanConnString

in

A pointer to the scanning socket as specified in the kavehost.xml file.

If you are using local communications via UNIX domain sockets, this parameter must point to the kavcomX socket, where X is the index of scanning kavehost process.

For more information, see section "Kavehost service configuration file".

pEventConnString

in

A pointer to the event socket as specified in the kavehost.xml file.

If you are using local communications via UNIX domain sockets, this parameter must point to the kavcom socket.

For more information, see section "Kavehost service configuration file".

dwOutprocScannersCount

in

This parameter defines the number of kavehost scanning processes.

If this parameter is set to 0, the default value 1 will be used instead.

The maximum permissible number of scanning processes is 256. If this number is greater than 256, the function returns E_INVALIDARG.

dwScanningThreadsCount

in

This parameter defines the maximum number of scanning threads running simultaneously.

If this parameter is set to 0, the default value 2 will be used instead.

This parameter defines the maximum number of scanning threads spawned by your client application that can be simultaneously handled by running scanning processes.

The scanning threads are distributed between scanning processes, number of which is specified by the dwOutprocScannerCount parameter. For example, if dwOutprocScannersCount is 4, and there are eight scanner threads, there will be two scanner threads in each scanner process.

If dwOutprocScannersCount is 4 and you set two scanner threads, there will be four scanner processes and four scanner threads (each scanner process handles one scanner thread).

The value specified in the <MaxScannersCount> element of the kavehost.xml file restricts the overall number of scanner processes, created by the kavehost service. For example, there are six clients which can connect to the kavehost service. As each client can create up to 256 scanning processes, you can set value of the <MaxScannersCount> element to 200. Actually, the value specified in the <MaxScannersCount> element depends on server performance and can be used to provide a kind of denial-of-service attack. For detailed information, see section "Kavehost service configuration file". The maximum permissible number of scanning threads is 256.

dwQueueLength

in

The maximum length of the scanning task queue. The queue is used in asynchronous scanning. All the scanning processes take the scanning tasks from a single queue.

If you set the dwQueueLength value to 0, the default value 1024 will be used instead.

To organize an infinite queue, set dwQueueLength to INFINITE or 0xFFFFFFFF.

The length can be changed later by calling the kaveSetQueueLen function.

pfnUserCallback

in

A pointer to the callback function. This function is called if one of the callback events occurs, for example, malware is detected, or an error occurs, or inquiry on disinfection is needed, or the user must be notified about scan completion, and so on.

dwNetworkTimeout

in

The maximum time, in milliseconds, for the service to wait for connection from the client. After the specified timeout expires, connection is considered lost.

This timeout is critical when connecting to the kavehost service that has no malware definitions ready to use in its memory. To reduce memory footprint, kavehost never loads the malware database at the start. Instead, it loads the database when it first receives the scanning request from the client side of KAV SDK (integrated into your application).

When working on Linux platform, it is recommended that you set this timeout to 1 minute or to a greater value, to compensate for the amount of time necessary for the kavehost service to load malware definition database into its memory. If you initialize the client with a shorter timeout, your client may disconnect from the kavehost service while the service is busy with loading malware definitions.

Return value

If the kaveInitializeService function succeeds, its return value is S_OK.

For other return codes, see section "Return codes".

Page top