tree: b753ccdefa0818af39ce84cee8f34ce524557a8b [path history] [tgz]
  1. client/
  2. fidl/
  3. meta/
  4. server/

ROT13 Example

rot13 (“rotate by 13 places”) takes a message a replaces each letter in the message with the letter 13th places after it in the alphabet. The rot13 sample has three parts: a client, a server, and a library defining a FIDL communication protocol between the components.

Source layout

  • fidl/: Contains the definition of a Fuchsia interprocess communication (IPC) protocol (fuchsia.examples.rot13.Rot13) for a rot13 server and client defined as a Fuchsia Interface Definition Language (FIDL) library. The file describes how to build the FIDL library that can be used as a dependency for the client and server.
  • server/: Contains the source for the rot13 echo server that takes rot13 encoded messages, decodes each message, then sends the decoded response back. The server handles incoming requests as FIDL messages received from the client.
  • client/: Contains the source for the rot13 echo client that sends string messages to a rot13 server for encoding and prints the results to the system log.
  • meta/: Top-level component realm to perform capability routing between the server and client components.

Before you begin

  1. Start a FEMU instance:

    $ ./third_party/fuchsia-sdk/bin/ -N
  2. Start a local package repository instance:

    $ ./third_party/fuchsia-sdk/bin/ --image qemu-x64

Build the sample

  1. Run the build script to compile and package the sample:

    $ ./scripts/
  2. Publish the FAR package to your local package repository:

    $ ./third_party/fuchsia-sdk/bin/ out/x64/rot13-example.far

Run the sample

  1. Launch the sample component using ffx component run. This resolves the component from the package repository and starts it:

    $ ffx component run fuchsia-pkg://
  2. View the result messages in the system log using ffx target log:

    $ ffx target log watch
    [rot13_realm/rot13_client] INFO: ***** Message: hello fuchsia has checksum of 1303
    [rot13_realm/rot13_client] INFO: Rotated message is uryyb shpufvn
    [rot13_realm/rot13_client] INFO: unrotated message = hello fuchsia
  3. Edit the client message using the args field in rot13_client.cml component manifest:

      program: {
        // ...
        // Program arguments
        args: [
            "hello fuchsia",
      // ...