echo example
echo example
The echo example demonstrates the use of IPC transport.
It shows how to use the main tools that let you implement interaction between programs.
The echo example describes a basic case of interaction between two programs:
- The
Clientprogram sends a number (value) to theServerprogram. - The
Serverprogram modifies this number and sends the new number (result) to theClientprogram. - The
Clientprogram prints theresultnumber to the screen.
To set up this interaction between programs:
- Connect the
ClientandServerprograms by using the init description. - On the server, implement an interface with a single
Pingmethod that has one input argument (the original number (value)) and one output argument (the modified number (result)).Description of the
Pingmethod in the IDL language:Ping(in UInt32 value, out UInt32 result);

- Create static description files in the EDL, CDL and IDL languages. Use the NK compiler to generate files containing transport methods and types (proxy object, dispatchers, etc.).
- In the code of the
Clientprogram, initialize all required objects (transport, proxy object, request structure, etc.) and call the interface method. - In the code of the
Serverprogram, prepare all the required objects (transport, component dispatcher and program dispatcher, etc.), accept the request from the client, process it and send a response.
Example files
The code of the example and build scripts are available at the following path:
/opt/KasperskyOS-Community-Edition-<version>/examples/echo
The echo example consists of the following source files:
client/src/client.ccontains implementation of theClientprogram.server/src/server.ccontains implementation of theServerprogram.resources/Server.edl,resources/Client.edl,resources/Responder.cdl,resources/Pingable.idlare static descriptions.init.yamlcontains the init description.
Building and running example
See Building and running examples section.
The build scheme for the echo example looks as follows:

Did you find this article helpful?
What can we do better?
Thank you for your feedback! You're helping us improve.
Thank you for your feedback! You're helping us improve.