# Writing your first C++ TANGO client

Intended audience: beginer developers, Programming language: c++

The quickest way of getting started is by studying this example :

     1  /*
     2   * example of a client using the TANGO C++ api.
     3   */
     4  #include <tango.h>
     5  using namespace Tango;
     6  int main(unsigned int argc, char **argv)
     7  {
     8      try
     9      {
    10
    11  //
    12  // create a connection to a TANGO device
    13  //
    14
    15          DeviceProxy *device = new DeviceProxy("sys/database/2");
    16
    17  //
    18  // Ping the device
    19  //
    20
    21          device->ping();
    22
    23  //
    24  // Execute a command on the device and extract the reply as a string
    25  //
    26
    27          string db_info;
    28          DeviceData cmd_reply;
    29          cmd_reply = device->command_inout("DbInfo");
    30          cmd_reply >> db_info;
    31          cout << "Command reply " << db_info << endl;
    32
    33  //
    34  // Read a device attribute (string data type)
    35  //
    36
    37          string spr;
    38          DeviceAttribute att_reply;
    39          att_reply = device->read_attribute("StoredProcedureRelease");
    40          att_reply >> spr;
    41          cout << "Database device stored procedure release: " << spr << endl;
    42      }
    43      catch (DevFailed &e)
    44      {
    45          Except::print_exception(e);
    46          exit(-1);
    47      }
    48  }

Modify this example to fit your device server or client’s needs, compile it and link with the library -ltango. Forget about those painful early TANGO days when you had to learn CORBA and manipulate Any’s. Life’s going to easy and fun from now on !