Changes between Version 3 and Version 4 of Documentation/Tutorial/PingPong


Ignore:
Timestamp:
Jan 20, 2009, 4:43:06 PM (16 years ago)
Author:
huebsch
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/Tutorial/PingPong

    v3 v4  
    1111As already mentioned, the example service simply exchanges packets between two participating network nodes. This is accomplished by using the ''Ariba'' abstraction to create a communication context and hide underlay details. The participants form a ''SpoVNet'' instance in which the first one (as the initiator) creates the instance, while the second joins. As soon as the second has successfully joined the instance, it starts sending packets to the initiator periodically. When such a packet reaches the latter, he responds by also sending a packet back. This procedure repeats, until a button is pressed.
    1212
     13'''How it does it'''
     14Let's take a look at the code now. Writing a service is pretty simple when using ''Ariba'' because most difficulties and annoyances that could come up when struggling with writing network code are taken from the developer. We start with the ''main.cpp''.
     15
     16
     17{{{
     1801 #include <string>
     1902 #include "ariba/utility/startup/StartupWrapper.h"
     2003 #include "PingPong.h"
     2104
     2205 using std::string;
     2306 using ariba::utility::StartupWrapper;
     2407 using ariba::application::pingpong::PingPong;
     2508
     2609 int main( int argc, char** argv ) {
     2710
     2811      string config = "../etc/settings.cnf";
     2912      if (argc >= 2) config = argv[1];
     3013
     3114      StartupWrapper::initConfig( config );
     3215      StartupWrapper::initSystem();
     3316     
     3417      // this will do the main functionality and block
     3518      PingPong ping;
     3619      ping.setMode( !Configuration::instance().read<bool>("GENERAL_Initiator") );
     3720      StartupWrapper::startup(&ping, true);
     3821
     3922      // this will run blocking until <enter> is hit
     4023
     4124      StartupWrapper::shutdown();
     4225      return 0;
     4326 }
     44}}}
     45The ''main.cpp'' serves us as an entry point to the application.
     46
     47
     48