Vector network functions sendvec() and recvvec()

The API is defined in the header file sysroot-*-kos/include/kos/vec_socket.h from the KasperskyOS SDK.

The API lets you send multiple network packets in a single IPC message, which speeds up network operations in KasperskyOS.

When using the send() or recv() functions of the standard C library, a separate IPC call is created for each call of these functions, which may slow down network operations. Due to the design of the KasperskyOS architecture, sending a large number of small packets results in a large number of IPC messages.

In contrast to the readv()/writev() functions of the standard C library, the sendvec()/recvvec() interface supports not only forwarding/receiving multiple packets at one socket but also forwarding/receiving multiple packets at multiple sockets.

Information about API functions is provided in the table below.

Using the API

To send packets, you must initialize the network interface, create sockets for connecting to the server, create and initialize the outvec structure containing the handles of sockets for connecting to the server and the pointers to packets to be sent, and then call the sendvec() function.

To receive packets, you must create sockets for receiving incoming connection requests, create and initialize the invec structure containing the handles of sockets for receiving packets and the pointers to buffers used to receive packets, accept incoming connection requests, and then call the recvvec() function.

Data structures for API are defined in the header file sysroot-*-kos/include/kos/vec_types.h from the KasperskyOS SDK.

Information about API functions

vec_socket.h functions

Function

Information about the function

sendvec()

Purpose

Sends multiple packets to multiple sockets in a single IPC message.

Parameters

  • [in,out] vec – pointer to the array containing the handles of sockets used to connect with the server and the pointers to the packets to be sent. The transmission results for each element (number of sent bytes or error) are also written to this array.

    The structure is defined in the header file sysroot-*-kos/include/kos/vec_types.h from the KasperskyOS SDK.

  • [in] count – number of elements in the vec parameter.

Returned values

If successful, the function returns the number of successfully sent packets, otherwise it returns an error code.

recvvec()

Purpose

Receives multiple packets from multiple sockets.

Parameters

  • [in,out] vec – pointer to the array containing the handles of sockets for receiving packets and the pointers to buffers used to receive packets. The receipt results for each element (number of received bytes or error) are also written to this array.

    The structure is defined in the header file sysroot-*-kos/include/kos/vec_types.h from the KasperskyOS SDK.

  • [in] count – number of elements in the vec parameter.

Returned values

If successful, the function returns the number of successfully received packets, otherwise it returns an error code.

Page top