KasperskyOS Community Edition 1.0

About the echo example

The echo example describes a basic case of interaction between two entities:

  1. The Client entity sends a number (value) to the Server entity.
  2. The Server entity modifies this number and sends the new number (result) to the Client entity.
  3. The Client entity prints the result to the screen.

To set up this interaction between entities:

  1. Connect the Client and Server entities by using the init description.
  2. On the server, implement an interface with a single Ping method that has one input argument (the original number (value)) and one output argument (the modified number (result)).

    Description of the Ping method in the IDL language:

    Ping(in UInt32 value, out UInt32 result);

  3. 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.).
  4. In the code of the Client entity, initialize all required objects (transport, proxy object, request structure, etc.) and call the interface method.
  5. In the code of the Server entity, prepare all the required objects (transport, component dispatcher and entity dispatcher, etc.), accept the request from the client, process it and send a response.

The echo example consists of the following source files:

  • client/src/client.c – implementation of the Client entity.
  • server/src/server.c – implementation of the Server entity.
  • resources/Server.edl, resources/Client.edl, resources/Ping.cdl, resources/Ping.idl – static descriptions.
  • init.yaml – init description.