EchoDevice

Files CCore/inc/net/EchoDevice.h CCore/src/net/EchoDevice.cpp

The class EchoDevice implements echo service. It can be attached to a packet multi-point device. Been attached the service simply reflects incoming packets. This class is useful in a net testing.


class EchoDevice : NoCopy , public PacketMultipointDevice::InboundProc , public PacketMultipointDevice::ConnectionProc
 {
   ....

  public:
  
   enum Event
    {
     Event_inbound,
     
     Event_nopacket,
     Event_badformat,
    
     Event_open,
     Event_lost,
     Event_close,

     EventLim
    };
    
   friend const char * GetTextDesc(Event ev); 

   using StatInfo = Counters<Event,EventLim> ;
    
  public: 
  
   static const ulen DefaultMaxPackets = 200 ;
  
   explicit EchoDevice(StrLen mp_dev_name,ulen max_packets=DefaultMaxPackets,bool show_flag=false);
   
   ~EchoDevice();
   
   void getStat(StatInfo &ret);
   
   uint64 getTraffic();
 };

Constructor attaches the object to the packet multi-point device, registered under the given name. max_packets limits the packet usage. If the show_flag is true, object will print messages about connection events to the console.

getStat() returns the device statistic.

getTraffic() returns the device traffic counter.